mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Refactor package to new namespace
This commit is contained in:
1 parent
089759dbad
commit
fd1e5232e0
55 files changed
+5632
-5624
No files matched your search
@@ -1,18 +1,21 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.h31ix.anticheat</groupId>
|
<groupId>net.gravitydevelopment.anticheat</groupId>
|
||||||
<artifactId>AntiCheat</artifactId>
|
<artifactId>AntiCheat</artifactId>
|
||||||
<version>1.5.9-DEV</version>
|
<version>2.0-DEV</version>
|
||||||
<name>AntiCheat</name>
|
<name>AntiCheat</name>
|
||||||
<url>http://gravitydevelopment.net</url>
|
<url>http://gravitydevelopment.net</url>
|
||||||
|
<properties>
|
||||||
|
<project.build.version>${project.version}</project.build.version>
|
||||||
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/repositories/public/</url>
|
<url>http://repo.bukkit.org/content/repositories/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>comphenix-rep</id>
|
<id>comphenix-repo</id>
|
||||||
<name>Comphenix Repository</name>
|
<name>Comphenix Repository</name>
|
||||||
<url>http://repo.comphenix.net/content/groups/public</url>
|
<url>http://repo.comphenix.net/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
@@ -31,21 +34,6 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>AntiCheat</finalName>
|
<finalName>AntiCheat</finalName>
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>.</targetPath>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<directory>${basedir}/src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>plugin.yml</include>
|
|
||||||
<include>config.yml</include>
|
|
||||||
<include>lang.yml</include>
|
|
||||||
<include>magic.yml</include>
|
|
||||||
<include>events.yml</include>
|
|
||||||
<include>enterprise.yml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<extensions>
|
<extensions>
|
||||||
<extension>
|
<extension>
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
@@ -53,7 +41,26 @@
|
|||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
</extension>
|
</extension>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
@@ -81,4 +88,5 @@
|
|||||||
<url>file:///var/lib/jenkins/repo</url>
|
<url>file:///var/lib/jenkins/repo</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
+10
-10
@@ -16,18 +16,18 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat;
|
package net.gravitydevelopment.anticheat;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.event.*;
|
import net.gravitydevelopment.anticheat.event.*;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
import net.gravitydevelopment.anticheat.manage.AnticheatManager;
|
||||||
import net.h31ix.anticheat.manage.PacketManager;
|
import net.gravitydevelopment.anticheat.manage.PacketManager;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.update.Updater;
|
import net.gravitydevelopment.anticheat.update.Updater;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import net.h31ix.anticheat.xray.XRayListener;
|
import net.gravitydevelopment.anticheat.xray.XRayListener;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
+489
-489
@@ -1,489 +1,489 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat;
|
package net.gravitydevelopment.anticheat;
|
||||||
|
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.manage.UserManager;
|
import net.gravitydevelopment.anticheat.manage.UserManager;
|
||||||
import net.h31ix.anticheat.util.*;
|
import net.gravitydevelopment.anticheat.util.*;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandHandler implements CommandExecutor {
|
public class CommandHandler implements CommandExecutor {
|
||||||
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
||||||
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
||||||
private static final XRayTracker XRAY_TRACKER = AntiCheat.getManager().getXRayTracker();
|
private static final XRayTracker XRAY_TRACKER = AntiCheat.getManager().getXRayTracker();
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
private static final ChatColor RED = ChatColor.RED;
|
||||||
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private List<String> high = new ArrayList<String>();
|
private List<String> high = new ArrayList<String>();
|
||||||
private List<String> med = new ArrayList<String>();
|
private List<String> med = new ArrayList<String>();
|
||||||
private List<String> low = new ArrayList<String>();
|
private List<String> low = new ArrayList<String>();
|
||||||
private static final Server SERVER = Bukkit.getServer();
|
private static final Server SERVER = Bukkit.getServer();
|
||||||
private static final int MED_THRESHOLD = 20;
|
private static final int MED_THRESHOLD = 20;
|
||||||
private static final int HIGH_THRESHOLD = 50;
|
private static final int HIGH_THRESHOLD = 50;
|
||||||
private static final String PERMISSIONS_ERROR = RED + "Insufficient Permissions.";
|
private static final String PERMISSIONS_ERROR = RED + "Insufficient Permissions.";
|
||||||
private static final String MENU_END = "-----------------------------------------------------";
|
private static final String MENU_END = "-----------------------------------------------------";
|
||||||
|
|
||||||
public void handleLog(CommandSender cs, String[] args) {
|
public void handleLog(CommandSender cs, String[] args) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_LOG)) {
|
if (hasPermission(cs, Permission.SYSTEM_LOG)) {
|
||||||
if (args[1].equalsIgnoreCase("enable")) {
|
if (args[1].equalsIgnoreCase("enable")) {
|
||||||
if (!CONFIG.getConfig().logToConsole.getValue()) {
|
if (!CONFIG.getConfig().logToConsole.getValue()) {
|
||||||
CONFIG.getConfig().logToConsole.setValue(true);
|
CONFIG.getConfig().logToConsole.setValue(true);
|
||||||
cs.sendMessage(GREEN + "Console logging enabled.");
|
cs.sendMessage(GREEN + "Console logging enabled.");
|
||||||
CONFIG.getConfig().reload();
|
CONFIG.getConfig().reload();
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(GREEN + "Console logging is already enabled!");
|
cs.sendMessage(GREEN + "Console logging is already enabled!");
|
||||||
}
|
}
|
||||||
} else if (args[1].equalsIgnoreCase("disable")) {
|
} else if (args[1].equalsIgnoreCase("disable")) {
|
||||||
if (CONFIG.getConfig().logToConsole.getValue()) {
|
if (CONFIG.getConfig().logToConsole.getValue()) {
|
||||||
CONFIG.getConfig().logToConsole.setValue(false);
|
CONFIG.getConfig().logToConsole.setValue(false);
|
||||||
cs.sendMessage(GREEN + "Console logging disabled.");
|
cs.sendMessage(GREEN + "Console logging disabled.");
|
||||||
CONFIG.getConfig().reload();
|
CONFIG.getConfig().reload();
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(GREEN + "Console logging is already disabled!");
|
cs.sendMessage(GREEN + "Console logging is already disabled!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Usage: /anticheat log [enable/disable]");
|
cs.sendMessage(RED + "Usage: /anticheat log [enable/disable]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDebug(CommandSender cs) {
|
public void handleDebug(CommandSender cs) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_DEBUG)) {
|
if (hasPermission(cs, Permission.SYSTEM_DEBUG)) {
|
||||||
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
||||||
PastebinReport report = new PastebinReport(cs);
|
PastebinReport report = new PastebinReport(cs);
|
||||||
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
||||||
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDebug(CommandSender cs, Player tp) {
|
public void handleDebug(CommandSender cs, Player tp) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
||||||
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
||||||
PastebinReport report = new PastebinReport(cs, tp);
|
PastebinReport report = new PastebinReport(cs, tp);
|
||||||
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
||||||
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleXRay(CommandSender cs, String[] args) {
|
public void handleXRay(CommandSender cs, String[] args) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_XRAY)) {
|
if (hasPermission(cs, Permission.SYSTEM_XRAY)) {
|
||||||
if (CONFIG.getConfig().logXRayStats.getValue()) {
|
if (CONFIG.getConfig().logXRayStats.getValue()) {
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
if (XRAY_TRACKER.sufficientData(player.getName())) {
|
if (XRAY_TRACKER.sufficientData(player.getName())) {
|
||||||
XRAY_TRACKER.sendStats(cs, player.getName());
|
XRAY_TRACKER.sendStats(cs, player.getName());
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
||||||
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||||
}
|
}
|
||||||
} else if (list.size() > 1) {
|
} else if (list.size() > 1) {
|
||||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
} else if (XRAY_TRACKER.sufficientData(args[1])) {
|
} else if (XRAY_TRACKER.sufficientData(args[1])) {
|
||||||
XRAY_TRACKER.sendStats(cs, args[1]);
|
XRAY_TRACKER.sendStats(cs, args[1]);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
||||||
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "XRay logging is off in the config.");
|
cs.sendMessage(RED + "XRay logging is off in the config.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReset(CommandSender cs, String[] args) {
|
public void handleReset(CommandSender cs, String[] args) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_RESET)) {
|
if (hasPermission(cs, Permission.SYSTEM_RESET)) {
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
User user = USER_MANAGER.getUser(player.getName());
|
User user = USER_MANAGER.getUser(player.getName());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.resetLevel();
|
user.resetLevel();
|
||||||
XRAY_TRACKER.reset(player.getName());
|
XRAY_TRACKER.reset(player.getName());
|
||||||
user.clearMessages();
|
user.clearMessages();
|
||||||
AntiCheat.getManager().getBackend().resetChatLevel(player);
|
AntiCheat.getManager().getBackend().resetChatLevel(player);
|
||||||
cs.sendMessage(player.getName() + GREEN + " has been reset.");
|
cs.sendMessage(player.getName() + GREEN + " has been reset.");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (list.size() > 1) {
|
} else if (list.size() > 1) {
|
||||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSpy(CommandSender cs, String[] args) {
|
public void handleSpy(CommandSender cs, String[] args) {
|
||||||
if (cs instanceof Player) {
|
if (cs instanceof Player) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_SPY)) {
|
if (hasPermission(cs, Permission.SYSTEM_SPY)) {
|
||||||
Player sender = (Player) cs;
|
Player sender = (Player) cs;
|
||||||
if (!args[1].equalsIgnoreCase("off")) {
|
if (!args[1].equalsIgnoreCase("off")) {
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
for (Player p : cs.getServer().getOnlinePlayers()) {
|
for (Player p : cs.getServer().getOnlinePlayers()) {
|
||||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
if (!Permission.SYSTEM_SPY.get(p)) {
|
||||||
p.hidePlayer(sender);
|
p.hidePlayer(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sender.hasMetadata(Utilities.SPY_METADATA)) // Maintain ORIGINAL location and other data
|
if (!sender.hasMetadata(Utilities.SPY_METADATA)) // Maintain ORIGINAL location and other data
|
||||||
{
|
{
|
||||||
SpyState state = new SpyState(sender.getAllowFlight(), sender.isFlying(), sender.getLocation());
|
SpyState state = new SpyState(sender.getAllowFlight(), sender.isFlying(), sender.getLocation());
|
||||||
sender.setMetadata(Utilities.SPY_METADATA, new FixedMetadataValue(AntiCheat.getPlugin(), state));
|
sender.setMetadata(Utilities.SPY_METADATA, new FixedMetadataValue(AntiCheat.getPlugin(), state));
|
||||||
}
|
}
|
||||||
sender.setAllowFlight(true);
|
sender.setAllowFlight(true);
|
||||||
sender.setFlying(true);
|
sender.setFlying(true);
|
||||||
sender.teleport(player);
|
sender.teleport(player);
|
||||||
sender.sendMessage(GREEN + "You have been teleported to " + player.getName() + " and made invisible.");
|
sender.sendMessage(GREEN + "You have been teleported to " + player.getName() + " and made invisible.");
|
||||||
sender.sendMessage(GREEN + "To stop spying, type " + WHITE + " /AntiCheat spy off");
|
sender.sendMessage(GREEN + "To stop spying, type " + WHITE + " /AntiCheat spy off");
|
||||||
} else if (list.size() > 1) {
|
} else if (list.size() > 1) {
|
||||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sender.hasMetadata(Utilities.SPY_METADATA)) {
|
if (sender.hasMetadata(Utilities.SPY_METADATA)) {
|
||||||
SpyState state = ((SpyState) sender.getMetadata(Utilities.SPY_METADATA).get(0).value());
|
SpyState state = ((SpyState) sender.getMetadata(Utilities.SPY_METADATA).get(0).value());
|
||||||
sender.setAllowFlight(state.getAllowFlight());
|
sender.setAllowFlight(state.getAllowFlight());
|
||||||
sender.setFlying(state.getFlying());
|
sender.setFlying(state.getFlying());
|
||||||
sender.teleport(state.getLocation());
|
sender.teleport(state.getLocation());
|
||||||
sender.removeMetadata(Utilities.SPY_METADATA, AntiCheat.getPlugin());
|
sender.removeMetadata(Utilities.SPY_METADATA, AntiCheat.getPlugin());
|
||||||
for (Player p : cs.getServer().getOnlinePlayers()) {
|
for (Player p : cs.getServer().getOnlinePlayers()) {
|
||||||
p.showPlayer(sender);
|
p.showPlayer(sender);
|
||||||
}
|
}
|
||||||
sender.sendMessage(GREEN + "Done spying! Brought you back to where you started!");
|
sender.sendMessage(GREEN + "Done spying! Brought you back to where you started!");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(RED + "You were not spying.");
|
sender.sendMessage(RED + "You were not spying.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Sorry, but you can't spy on a player from the console.");
|
cs.sendMessage(RED + "Sorry, but you can't spy on a player from the console.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleHelp(CommandSender cs) {
|
public void handleHelp(CommandSender cs) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_HELP)) {
|
if (hasPermission(cs, Permission.SYSTEM_HELP)) {
|
||||||
String base = "/AntiCheat ";
|
String base = "/AntiCheat ";
|
||||||
String[] lines = {
|
String[] lines = {
|
||||||
"log [Enable/Disable]" + WHITE + " - toggle logging",
|
"log [Enable/Disable]" + WHITE + " - toggle logging",
|
||||||
"report [low/medium/high]" + WHITE + " - show users in groups",
|
"report [low/medium/high]" + WHITE + " - show users in groups",
|
||||||
"report [user]" + WHITE + " - get a player's cheat report",
|
"report [user]" + WHITE + " - get a player's cheat report",
|
||||||
"reload" + WHITE + " - reload AntiCheat configuration",
|
"reload" + WHITE + " - reload AntiCheat configuration",
|
||||||
"reset [user]" + WHITE + " - reset user's hack level",
|
"reset [user]" + WHITE + " - reset user's hack level",
|
||||||
"xray [user]" + WHITE + " - check user's xray levels",
|
"xray [user]" + WHITE + " - check user's xray levels",
|
||||||
"spy [user]" + WHITE + " - spy on a user in secret",
|
"spy [user]" + WHITE + " - spy on a user in secret",
|
||||||
"help" + WHITE + " - access this page",
|
"help" + WHITE + " - access this page",
|
||||||
"debug" + WHITE + " - post debug information",
|
"debug" + WHITE + " - post debug information",
|
||||||
"update" + WHITE + " - check update status",
|
"update" + WHITE + " - check update status",
|
||||||
};
|
};
|
||||||
|
|
||||||
cs.sendMessage("----------------------[" + GREEN + "AntiCheat" + WHITE + "]----------------------");
|
cs.sendMessage("----------------------[" + GREEN + "AntiCheat" + WHITE + "]----------------------");
|
||||||
for (String s : lines) {
|
for (String s : lines) {
|
||||||
cs.sendMessage(base + GREEN + s);
|
cs.sendMessage(base + GREEN + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleUpdate(CommandSender cs) {
|
public void handleUpdate(CommandSender cs) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_UPDATE)) {
|
if (hasPermission(cs, Permission.SYSTEM_UPDATE)) {
|
||||||
cs.sendMessage("Running " + GREEN + "AntiCheat " + WHITE + "v" + GREEN + AntiCheat.getVersion());
|
cs.sendMessage("Running " + GREEN + "AntiCheat " + WHITE + "v" + GREEN + AntiCheat.getVersion());
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
if (!AntiCheat.isUpdated()) {
|
if (!AntiCheat.isUpdated()) {
|
||||||
cs.sendMessage(GRAY + "There " + GREEN + "IS" + GRAY + " a newer version avaliable.");
|
cs.sendMessage(GRAY + "There " + GREEN + "IS" + GRAY + " a newer version avaliable.");
|
||||||
if (CONFIG.getConfig().autoUpdate.getValue()) {
|
if (CONFIG.getConfig().autoUpdate.getValue()) {
|
||||||
cs.sendMessage(GRAY + "It will be installed automatically for you on next launch.");
|
cs.sendMessage(GRAY + "It will be installed automatically for you on next launch.");
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(GRAY + "Due to your config settings, we " + RED + "can not" + GRAY + " auto update.");
|
cs.sendMessage(GRAY + "Due to your config settings, we " + RED + "can not" + GRAY + " auto update.");
|
||||||
cs.sendMessage(GRAY + "Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
cs.sendMessage(GRAY + "Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(GRAY + "AntiCheat is " + GREEN + "UP TO DATE!");
|
cs.sendMessage(GRAY + "AntiCheat is " + GREEN + "UP TO DATE!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCalibrate(CommandSender cs) {
|
public void handleCalibrate(CommandSender cs) {
|
||||||
if (cs instanceof Player) {
|
if (cs instanceof Player) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_CALIBRATE)) {
|
if (hasPermission(cs, Permission.SYSTEM_CALIBRATE)) {
|
||||||
Calibrator c = new Calibrator((Player) cs);
|
Calibrator c = new Calibrator((Player) cs);
|
||||||
SERVER.getPluginManager().registerEvents(c, AntiCheat.getPlugin());
|
SERVER.getPluginManager().registerEvents(c, AntiCheat.getPlugin());
|
||||||
c.calibrate();
|
c.calibrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReport(CommandSender cs, String[] args) {
|
public void handleReport(CommandSender cs, String[] args) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
String group = args[1];
|
String group = args[1];
|
||||||
if (group.equalsIgnoreCase("low")) {
|
if (group.equalsIgnoreCase("low")) {
|
||||||
int num = getReportPageNum(args);
|
int num = getReportPageNum(args);
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
sendReport(cs, low, "Low", GREEN, num);
|
sendReport(cs, low, "Low", GREEN, num);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||||
}
|
}
|
||||||
} else if (group.equalsIgnoreCase("medium")) {
|
} else if (group.equalsIgnoreCase("medium")) {
|
||||||
int num = getReportPageNum(args);
|
int num = getReportPageNum(args);
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
sendReport(cs, med, "Medium", YELLOW, num);
|
sendReport(cs, med, "Medium", YELLOW, num);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group.equalsIgnoreCase("high")) {
|
if (group.equalsIgnoreCase("high")) {
|
||||||
int num = getReportPageNum(args);
|
int num = getReportPageNum(args);
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
sendReport(cs, high, "High", RED, num);
|
sendReport(cs, high, "High", RED, num);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReportPageNum(String[] args) {
|
public int getReportPageNum(String[] args) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (Utilities.isInt(args[2])) {
|
} else if (Utilities.isInt(args[2])) {
|
||||||
return Integer.parseInt(args[2]);
|
return Integer.parseInt(args[2]);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendReport(CommandSender cs, List<String> players, String group, ChatColor color, int page) {
|
public void sendReport(CommandSender cs, List<String> players, String group, ChatColor color, int page) {
|
||||||
int pages = (int) Math.ceil(((float) players.size()) / 7);
|
int pages = (int) Math.ceil(((float) players.size()) / 7);
|
||||||
if (page <= pages && page > 0) {
|
if (page <= pages && page > 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY + "Group: " + color + group);
|
cs.sendMessage(GRAY + "Group: " + color + group);
|
||||||
for (int x = 0; x < 7; x++) {
|
for (int x = 0; x < 7; x++) {
|
||||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||||
if (index < players.size()) {
|
if (index < players.size()) {
|
||||||
String player = players.get(index);
|
String player = players.get(index);
|
||||||
cs.sendMessage(GRAY + player);
|
cs.sendMessage(GRAY + player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
if (pages == 0) {
|
if (pages == 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY + "Group: " + color + group);
|
cs.sendMessage(GRAY + "Group: " + color + group);
|
||||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handlePlayerReport(CommandSender cs, String[] args) {
|
public void handlePlayerReport(CommandSender cs, String[] args) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
if (hasPermission(cs, Permission.SYSTEM_REPORT)) {
|
||||||
User user = AntiCheat.getManager().getUserManager().getUser(args[1]);
|
User user = AntiCheat.getManager().getUserManager().getUser(args[1]);
|
||||||
boolean cont = false;
|
boolean cont = false;
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
if ((user = AntiCheat.getManager().getUserManager().getUser(args[1])) == null) {
|
if ((user = AntiCheat.getManager().getUserManager().getUser(args[1])) == null) {
|
||||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
} else {
|
} else {
|
||||||
cont = true;
|
cont = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cont = true;
|
cont = true;
|
||||||
}
|
}
|
||||||
if (cont) {
|
if (cont) {
|
||||||
List<CheckType> l = new ArrayList<CheckType>();
|
List<CheckType> l = new ArrayList<CheckType>();
|
||||||
for (CheckType type : CheckType.values()) {
|
for (CheckType type : CheckType.values()) {
|
||||||
if (type.getUses(user.getName()) > 0) {
|
if (type.getUses(user.getName()) > 0) {
|
||||||
l.add(type);
|
l.add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
sendPlayerReport(cs, l, user, 1);
|
sendPlayerReport(cs, l, user, 1);
|
||||||
} else if (Utilities.isInt(args[2])) {
|
} else if (Utilities.isInt(args[2])) {
|
||||||
int num = Integer.parseInt(args[2]);
|
int num = Integer.parseInt(args[2]);
|
||||||
sendPlayerReport(cs, l, user, num);
|
sendPlayerReport(cs, l, user, num);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDeveloper(CommandSender cs) {
|
public void handleDeveloper(CommandSender cs) {
|
||||||
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
|
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
|
||||||
cs.sendMessage(ChatColor.GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
|
cs.sendMessage(ChatColor.GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerReport(CommandSender cs, List<CheckType> types, User user, int page) {
|
public void sendPlayerReport(CommandSender cs, List<CheckType> types, User user, int page) {
|
||||||
String name = user.getName();
|
String name = user.getName();
|
||||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||||
|
|
||||||
Level level = user.getNamedLevel();
|
Level level = user.getNamedLevel();
|
||||||
String levelString = ChatColor.GREEN + "Low";
|
String levelString = ChatColor.GREEN + "Low";
|
||||||
|
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
levelString = level.getColor() + level.getName();
|
levelString = level.getColor() + level.getName();
|
||||||
}
|
}
|
||||||
levelString += " (" + user.getLevel() + ")";
|
levelString += " (" + user.getLevel() + ")";
|
||||||
|
|
||||||
if (page <= pages && page > 0) {
|
if (page <= pages && page > 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
cs.sendMessage(GRAY + "Level: " + levelString);
|
cs.sendMessage(GRAY + "Level: " + levelString);
|
||||||
for (int x = 0; x < 6; x++) {
|
for (int x = 0; x < 6; x++) {
|
||||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||||
if (index < types.size()) {
|
if (index < types.size()) {
|
||||||
int use = types.get(index).getUses(name);
|
int use = types.get(index).getUses(name);
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if (use >= 20) {
|
if (use >= 20) {
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
} else if (use > 50) {
|
} else if (use > 50) {
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY + CheckType.getName(types.get(index)) + ": " + color + use);
|
cs.sendMessage(GRAY + CheckType.getName(types.get(index)) + ": " + color + use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
if (pages == 0) {
|
if (pages == 0) {
|
||||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||||
cs.sendMessage(GRAY + "Level: " + levelString);
|
cs.sendMessage(GRAY + "Level: " + levelString);
|
||||||
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
||||||
cs.sendMessage(MENU_END);
|
cs.sendMessage(MENU_END);
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReload(CommandSender cs) {
|
public void handleReload(CommandSender cs) {
|
||||||
if (hasPermission(cs, Permission.SYSTEM_RELOAD)) {
|
if (hasPermission(cs, Permission.SYSTEM_RELOAD)) {
|
||||||
CONFIG.load();
|
CONFIG.load();
|
||||||
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args) {
|
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args) {
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (args[0].equalsIgnoreCase("report")) {
|
if (args[0].equalsIgnoreCase("report")) {
|
||||||
for (Level level : CONFIG.getEvents().getLevels()) {
|
for (Level level : CONFIG.getEvents().getLevels()) {
|
||||||
if (args[1].equalsIgnoreCase(level.getName())) {
|
if (args[1].equalsIgnoreCase(level.getName())) {
|
||||||
handleReport(cs, args);
|
handleReport(cs, args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handlePlayerReport(cs, args);
|
handlePlayerReport(cs, args);
|
||||||
}
|
}
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("log")) {
|
if (args[0].equalsIgnoreCase("log")) {
|
||||||
handleLog(cs, args);
|
handleLog(cs, args);
|
||||||
} else if (args[0].equalsIgnoreCase("xray")) {
|
} else if (args[0].equalsIgnoreCase("xray")) {
|
||||||
handleXRay(cs, args);
|
handleXRay(cs, args);
|
||||||
} else if (args[0].equalsIgnoreCase("debug")) {
|
} else if (args[0].equalsIgnoreCase("debug")) {
|
||||||
handleDebug(cs, Bukkit.getPlayer(args[1]));
|
handleDebug(cs, Bukkit.getPlayer(args[1]));
|
||||||
} else if (args[0].equalsIgnoreCase("reset")) {
|
} else if (args[0].equalsIgnoreCase("reset")) {
|
||||||
handleReset(cs, args);
|
handleReset(cs, args);
|
||||||
} else if (args[0].equalsIgnoreCase("spy")) {
|
} else if (args[0].equalsIgnoreCase("spy")) {
|
||||||
handleSpy(cs, args);
|
handleSpy(cs, args);
|
||||||
} else if (args[0].equalsIgnoreCase("report")) {
|
} else if (args[0].equalsIgnoreCase("report")) {
|
||||||
if (args[1].equalsIgnoreCase("low") || args[1].equalsIgnoreCase("medium") || args[1].equalsIgnoreCase("high")) {
|
if (args[1].equalsIgnoreCase("low") || args[1].equalsIgnoreCase("medium") || args[1].equalsIgnoreCase("high")) {
|
||||||
handleReport(cs, args);
|
handleReport(cs, args);
|
||||||
} else {
|
} else {
|
||||||
handlePlayerReport(cs, args);
|
handlePlayerReport(cs, args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(RED + "Unrecognized command.");
|
cs.sendMessage(RED + "Unrecognized command.");
|
||||||
}
|
}
|
||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("help")) {
|
if (args[0].equalsIgnoreCase("help")) {
|
||||||
handleHelp(cs);
|
handleHelp(cs);
|
||||||
} else if (args[0].equalsIgnoreCase("debug")) {
|
} else if (args[0].equalsIgnoreCase("debug")) {
|
||||||
handleDebug(cs);
|
handleDebug(cs);
|
||||||
} else if (args[0].equalsIgnoreCase("report")) {
|
} else if (args[0].equalsIgnoreCase("report")) {
|
||||||
cs.sendMessage(ChatColor.GREEN + "To see the report of a specific user, type their name, like so:");
|
cs.sendMessage(ChatColor.GREEN + "To see the report of a specific user, type their name, like so:");
|
||||||
cs.sendMessage(ChatColor.WHITE + "/anticheat report [user]");
|
cs.sendMessage(ChatColor.WHITE + "/anticheat report [user]");
|
||||||
cs.sendMessage(ChatColor.GRAY + " - This will allow you to see the checks that user has failed.");
|
cs.sendMessage(ChatColor.GRAY + " - This will allow you to see the checks that user has failed.");
|
||||||
cs.sendMessage(ChatColor.GREEN + "To see the report of an AntiCheat group, type it's name, like so:");
|
cs.sendMessage(ChatColor.GREEN + "To see the report of an AntiCheat group, type it's name, like so:");
|
||||||
cs.sendMessage(ChatColor.WHITE + "/anticheat report [low/medium/high]");
|
cs.sendMessage(ChatColor.WHITE + "/anticheat report [low/medium/high]");
|
||||||
cs.sendMessage(ChatColor.GRAY + " - This will allow you to see which players are good, and which could be hacking.");
|
cs.sendMessage(ChatColor.GRAY + " - This will allow you to see which players are good, and which could be hacking.");
|
||||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
handleReload(cs);
|
handleReload(cs);
|
||||||
} else if (args[0].equalsIgnoreCase("update")) {
|
} else if (args[0].equalsIgnoreCase("update")) {
|
||||||
handleUpdate(cs);
|
handleUpdate(cs);
|
||||||
} else if (args[0].equalsIgnoreCase("developer")) {
|
} else if (args[0].equalsIgnoreCase("developer")) {
|
||||||
handleDeveloper(cs);
|
handleDeveloper(cs);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* else if (args[0].equalsIgnoreCase("calibrate")) { handleCalibrate(cs); }
|
* else if (args[0].equalsIgnoreCase("calibrate")) { handleCalibrate(cs); }
|
||||||
*/
|
*/
|
||||||
else {
|
else {
|
||||||
cs.sendMessage(RED + "Unrecognized command.");
|
cs.sendMessage(RED + "Unrecognized command.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleHelp(cs); // Handle no args as alias of help
|
handleHelp(cs); // Handle no args as alias of help
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPlayers() {
|
public void getPlayers() {
|
||||||
high.clear();
|
high.clear();
|
||||||
med.clear();
|
med.clear();
|
||||||
low.clear();
|
low.clear();
|
||||||
for (Player player : SERVER.getOnlinePlayers()) {
|
for (Player player : SERVER.getOnlinePlayers()) {
|
||||||
int level = USER_MANAGER.safeGetLevel(player.getName());
|
int level = USER_MANAGER.safeGetLevel(player.getName());
|
||||||
if (level <= MED_THRESHOLD) {
|
if (level <= MED_THRESHOLD) {
|
||||||
low.add(player.getName());
|
low.add(player.getName());
|
||||||
} else if (level <= HIGH_THRESHOLD) {
|
} else if (level <= HIGH_THRESHOLD) {
|
||||||
med.add(player.getName());
|
med.add(player.getName());
|
||||||
} else {
|
} else {
|
||||||
high.add(player.getName());
|
high.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(CommandSender cs, Permission perm) {
|
public boolean hasPermission(CommandSender cs, Permission perm) {
|
||||||
if (perm.get(cs)) {
|
if (perm.get(cs)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + perm.toString() + RED + ")");
|
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + perm.toString() + RED + ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+156
-156
@@ -1,156 +1,156 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.api;
|
package net.gravitydevelopment.anticheat.api;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
import net.gravitydevelopment.anticheat.manage.AnticheatManager;
|
||||||
import net.h31ix.anticheat.manage.CheckManager;
|
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.UserManager;
|
import net.gravitydevelopment.anticheat.manage.UserManager;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Developer's interface for all things AntiCheat.
|
* Developer's interface for all things AntiCheat.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AnticheatAPI {
|
public class AnticheatAPI {
|
||||||
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
|
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
|
||||||
private static UserManager umr = AntiCheat.getManager().getUserManager();
|
private static UserManager umr = AntiCheat.getManager().getUserManager();
|
||||||
private static XRayTracker xtracker = AntiCheat.getManager().getXRayTracker();
|
private static XRayTracker xtracker = AntiCheat.getManager().getXRayTracker();
|
||||||
|
|
||||||
// CheckManager API
|
// CheckManager API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start running a certain check
|
* Start running a certain check
|
||||||
*
|
*
|
||||||
* @param type Check to start watching for
|
* @param type Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void activateCheck(CheckType type) {
|
public static void activateCheck(CheckType type) {
|
||||||
chk.activateCheck(type);
|
chk.activateCheck(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop running a certain check
|
* Stop running a certain check
|
||||||
*
|
*
|
||||||
* @param type Check to stop watching for
|
* @param type Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void deactivateCheck(CheckType type) {
|
public static void deactivateCheck(CheckType type) {
|
||||||
chk.deactivateCheck(type);
|
chk.deactivateCheck(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a check is currently being watched for
|
* Find out if a check is currently being watched for
|
||||||
*
|
*
|
||||||
* @param type Type to check
|
* @param type Type to check
|
||||||
* @return true if plugin is watching for this check
|
* @return true if plugin is watching for this check
|
||||||
*/
|
*/
|
||||||
public static boolean isActive(CheckType type) {
|
public static boolean isActive(CheckType type) {
|
||||||
return chk.isActive(type);
|
return chk.isActive(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow a player to skip a certain check
|
* Allow a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to stop watching
|
* @param player Player to stop watching
|
||||||
* @param type Check to stop watching for
|
* @param type Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void exemptPlayer(Player player, CheckType type) {
|
public static void exemptPlayer(Player player, CheckType type) {
|
||||||
chk.exemptPlayer(player, type);
|
chk.exemptPlayer(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop allowing a player to skip a certain check
|
* Stop allowing a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to start watching
|
* @param player Player to start watching
|
||||||
* @param type Check to start watching for
|
* @param type Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void unexemptPlayer(Player player, CheckType type) {
|
public static void unexemptPlayer(Player player, CheckType type) {
|
||||||
chk.unexemptPlayer(player, type);
|
chk.unexemptPlayer(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a player is currently exempt from a certain check
|
* Find out if a player is currently exempt from a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @param type Type to check
|
* @param type Type to check
|
||||||
* @return true if plugin is ignoring this check on this player
|
* @return true if plugin is ignoring this check on this player
|
||||||
*/
|
*/
|
||||||
public static boolean isExempt(Player player, CheckType type) {
|
public static boolean isExempt(Player player, CheckType type) {
|
||||||
return chk.isExempt(player, type);
|
return chk.isExempt(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a check will occur for a player. This checks if they are being tracked, the check is active, the player isn't exempt from the check, and the player doesn't have override permission.
|
* Find out if a check will occur for a player. This checks if they are being tracked, the check is active, the player isn't exempt from the check, and the player doesn't have override permission.
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @param type Type to check
|
* @param type Type to check
|
||||||
* @return true if plugin will check this player, and that all things allow it to happen.
|
* @return true if plugin will check this player, and that all things allow it to happen.
|
||||||
*/
|
*/
|
||||||
public boolean willCheck(Player player, CheckType type) {
|
public boolean willCheck(Player player, CheckType type) {
|
||||||
return chk.willCheck(player, type);
|
return chk.willCheck(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlayerManager API
|
// PlayerManager API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's integer hack level
|
* Get a player's integer hack level
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @return player's hack level
|
* @return player's hack level
|
||||||
*/
|
*/
|
||||||
public static int getLevel(Player player) {
|
public static int getLevel(Player player) {
|
||||||
return umr.safeGetLevel(player.getName());
|
return umr.safeGetLevel(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a player's hack level (Min = 0, Max = 50)
|
* Set a player's hack level (Min = 0, Max = 50)
|
||||||
*
|
*
|
||||||
* @param player Player to set
|
* @param player Player to set
|
||||||
* @param level Level to set to
|
* @param level Level to set to
|
||||||
*/
|
*/
|
||||||
public static void setLevel(Player player, int level) {
|
public static void setLevel(Player player, int level) {
|
||||||
umr.safeSetLevel(player.getName(), level);
|
umr.safeSetLevel(player.getName(), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XrayTracker API
|
// XrayTracker API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a player is detected as using xray hacks (on any ore)
|
* Find out if a player is detected as using xray hacks (on any ore)
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @return true if the player has any xray anomalies.
|
* @return true if the player has any xray anomalies.
|
||||||
*/
|
*/
|
||||||
public static boolean isXrayer(Player player) {
|
public static boolean isXrayer(Player player) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
return xtracker.sufficientData(name) && xtracker.hasAbnormal(name);
|
return xtracker.sufficientData(name) && xtracker.hasAbnormal(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advanced Users Only API.
|
// Advanced Users Only API.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get access to all the other managers, advanced users ONLY
|
* Get access to all the other managers, advanced users ONLY
|
||||||
*
|
*
|
||||||
* @return the AntiCheat Manager
|
* @return the AntiCheat Manager
|
||||||
*/
|
*/
|
||||||
public static AnticheatManager getManager() {
|
public static AnticheatManager getManager() {
|
||||||
return AntiCheat.getManager();
|
return AntiCheat.getManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-7
@@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.api;
|
package net.gravitydevelopment.anticheat.api;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@@ -40,18 +40,18 @@ public class CheckFailEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link net.h31ix.anticheat.manage.User} who failed the check
|
* Get the {@link net.gravitydevelopment.anticheat.manage.User} who failed the check
|
||||||
*
|
*
|
||||||
* @return a {@link net.h31ix.anticheat.manage.User}
|
* @return a {@link net.gravitydevelopment.anticheat.manage.User}
|
||||||
*/
|
*/
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link net.h31ix.anticheat.manage.CheckType} failed
|
* Get the {@link net.gravitydevelopment.anticheat.manage.CheckType} failed
|
||||||
*
|
*
|
||||||
* @return a {@link net.h31ix.anticheat.manage.CheckType}
|
* @return a {@link net.gravitydevelopment.anticheat.manage.CheckType}
|
||||||
*/
|
*/
|
||||||
public CheckType getCheck() {
|
public CheckType getCheck() {
|
||||||
return type;
|
return type;
|
||||||
+15
-15
@@ -16,22 +16,22 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config;
|
package net.gravitydevelopment.anticheat.config;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.files.Config;
|
import net.gravitydevelopment.anticheat.config.files.Config;
|
||||||
import net.h31ix.anticheat.config.files.Enterprise;
|
import net.gravitydevelopment.anticheat.config.files.Enterprise;
|
||||||
import net.h31ix.anticheat.config.files.Lang;
|
import net.gravitydevelopment.anticheat.config.files.Lang;
|
||||||
import net.h31ix.anticheat.config.files.Magic;
|
import net.gravitydevelopment.anticheat.config.files.Magic;
|
||||||
import net.h31ix.anticheat.config.holders.mysql.MySQLEventsHolder;
|
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLEventsHolder;
|
||||||
import net.h31ix.anticheat.config.holders.mysql.MySQLLevelsHolder;
|
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLLevelsHolder;
|
||||||
import net.h31ix.anticheat.config.holders.mysql.MySQLRulesHolder;
|
import net.gravitydevelopment.anticheat.config.holders.mysql.MySQLRulesHolder;
|
||||||
import net.h31ix.anticheat.config.holders.yaml.YamlEventsHolder;
|
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlEventsHolder;
|
||||||
import net.h31ix.anticheat.config.holders.yaml.YamlLevelsHolder;
|
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlLevelsHolder;
|
||||||
import net.h31ix.anticheat.config.holders.yaml.YamlRulesHolder;
|
import net.gravitydevelopment.anticheat.config.holders.yaml.YamlRulesHolder;
|
||||||
import net.h31ix.anticheat.config.providers.Events;
|
import net.gravitydevelopment.anticheat.config.providers.Events;
|
||||||
import net.h31ix.anticheat.config.providers.Levels;
|
import net.gravitydevelopment.anticheat.config.providers.Levels;
|
||||||
import net.h31ix.anticheat.config.providers.Rules;
|
import net.gravitydevelopment.anticheat.config.providers.Rules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
+3
-3
@@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config;
|
package net.gravitydevelopment.anticheat.config;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.yaml.CommentedConfiguration;
|
import net.gravitydevelopment.anticheat.config.yaml.CommentedConfiguration;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
+2
-2
@@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config;
|
package net.gravitydevelopment.anticheat.config;
|
||||||
|
|
||||||
import net.h31ix.anticheat.util.enterprise.Database;
|
import net.gravitydevelopment.anticheat.util.enterprise.Database;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
+4
-4
@@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.files;
|
package net.gravitydevelopment.anticheat.config.files;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+5
-5
@@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.files;
|
package net.gravitydevelopment.anticheat.config.files;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
import net.h31ix.anticheat.util.enterprise.Database;
|
import net.gravitydevelopment.anticheat.util.enterprise.Database;
|
||||||
|
|
||||||
public class Enterprise extends ConfigurationFile {
|
public class Enterprise extends ConfigurationFile {
|
||||||
|
|
||||||
+4
-4
@@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.files;
|
package net.gravitydevelopment.anticheat.config.files;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+4
-4
@@ -16,11 +16,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.files;
|
package net.gravitydevelopment.anticheat.config.files;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
||||||
+5
-5
@@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.mysql;
|
package net.gravitydevelopment.anticheat.config.holders.mysql;
|
||||||
|
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationTable;
|
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
||||||
import net.h31ix.anticheat.config.providers.Events;
|
import net.gravitydevelopment.anticheat.config.providers.Events;
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.gravitydevelopment.anticheat.util.Level;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
+6
-6
@@ -16,13 +16,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.mysql;
|
package net.gravitydevelopment.anticheat.config.holders.mysql;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationTable;
|
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
||||||
import net.h31ix.anticheat.config.providers.Levels;
|
import net.gravitydevelopment.anticheat.config.providers.Levels;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
+6
-6
@@ -16,13 +16,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.mysql;
|
package net.gravitydevelopment.anticheat.config.holders.mysql;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationTable;
|
import net.gravitydevelopment.anticheat.config.ConfigurationTable;
|
||||||
import net.h31ix.anticheat.config.providers.Rules;
|
import net.gravitydevelopment.anticheat.config.providers.Rules;
|
||||||
import net.h31ix.anticheat.util.rule.Rule;
|
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
+6
-6
@@ -16,13 +16,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.yaml;
|
package net.gravitydevelopment.anticheat.config.holders.yaml;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
import net.h31ix.anticheat.config.providers.Events;
|
import net.gravitydevelopment.anticheat.config.providers.Events;
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.gravitydevelopment.anticheat.util.Level;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
+6
-6
@@ -16,13 +16,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.yaml;
|
package net.gravitydevelopment.anticheat.config.holders.yaml;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
import net.h31ix.anticheat.config.providers.Levels;
|
import net.gravitydevelopment.anticheat.config.providers.Levels;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+6
-6
@@ -16,13 +16,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.holders.yaml;
|
package net.gravitydevelopment.anticheat.config.holders.yaml;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
import net.gravitydevelopment.anticheat.config.ConfigurationFile;
|
||||||
import net.h31ix.anticheat.config.providers.Rules;
|
import net.gravitydevelopment.anticheat.config.providers.Rules;
|
||||||
import net.h31ix.anticheat.util.rule.Rule;
|
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
+2
-2
@@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.providers;
|
package net.gravitydevelopment.anticheat.config.providers;
|
||||||
|
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.gravitydevelopment.anticheat.util.Level;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+2
-2
@@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.providers;
|
package net.gravitydevelopment.anticheat.config.providers;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+2
-2
@@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.providers;
|
package net.gravitydevelopment.anticheat.config.providers;
|
||||||
|
|
||||||
import net.h31ix.anticheat.util.rule.Rule;
|
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.config.yaml;
|
package net.gravitydevelopment.anticheat.config.yaml;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
+108
-108
@@ -1,108 +1,108 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.util.CheckResult;
|
import net.gravitydevelopment.anticheat.util.CheckResult;
|
||||||
import net.h31ix.anticheat.util.Distance;
|
import net.gravitydevelopment.anticheat.util.Distance;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
public class BlockListener extends EventListener {
|
public class BlockListener extends EventListener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
|
if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
|
||||||
getBackend().logInstantBreak(player);
|
getBackend().logInstantBreak(player);
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
||||||
CheckResult result = getBackend().checkAutoTool(player);
|
CheckResult result = getBackend().checkAutoTool(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (player != null && getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
if (player != null && getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
||||||
CheckResult result = getBackend().checkFastPlace(player);
|
CheckResult result = getBackend().checkFastPlace(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
||||||
} else {
|
} else {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
getBackend().logBlockPlace(player);
|
getBackend().logBlockPlace(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
boolean noHack = true;
|
boolean noHack = true;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
CheckResult result;
|
CheckResult result;
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) {
|
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) {
|
||||||
result = getBackend().checkFastBreak(player, block);
|
result = getBackend().checkFastBreak(player, block);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_BREAK);
|
log(result.getMessage(), player, CheckType.FAST_BREAK);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
||||||
result = getBackend().checkSwing(player, block);
|
result = getBackend().checkSwing(player, block);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.NO_SWING);
|
log(result.getMessage(), player, CheckType.NO_SWING);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.LONG_REACH)) {
|
if (getCheckManager().willCheck(player, CheckType.LONG_REACH)) {
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
result = getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
result = getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.LONG_REACH);
|
log(result.getMessage(), player, CheckType.LONG_REACH);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (noHack) {
|
if (noHack) {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
getBackend().logBlockBreak(player);
|
getBackend().logBlockBreak(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+175
-175
@@ -1,175 +1,175 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.util.CheckResult;
|
import net.gravitydevelopment.anticheat.util.CheckResult;
|
||||||
import net.h31ix.anticheat.util.Distance;
|
import net.gravitydevelopment.anticheat.util.Distance;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
|
|
||||||
public class EntityListener extends EventListener {
|
public class EntityListener extends EventListener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) {
|
if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) {
|
||||||
CheckResult result = getBackend().checkFastBow(player, event.getForce());
|
CheckResult result = getBackend().checkFastBow(player, event.getForce());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_BOW);
|
log(result.getMessage(), player, CheckType.FAST_BOW);
|
||||||
} else {
|
} else {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||||
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
|
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
|
if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
|
||||||
CheckResult result = getBackend().checkFastHeal(player);
|
CheckResult result = getBackend().checkFastHeal(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_HEAL);
|
log(result.getMessage(), player, CheckType.FAST_HEAL);
|
||||||
} else {
|
} else {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
getBackend().logHeal(player);
|
getBackend().logHeal(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (player.getFoodLevel() < event.getFoodLevel() && getCheckManager().willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
|
if (player.getFoodLevel() < event.getFoodLevel() && getCheckManager().willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
|
||||||
{
|
{
|
||||||
CheckResult result = getBackend().checkFastEat(player);
|
CheckResult result = getBackend().checkFastEat(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_EAT);
|
log(result.getMessage(), player, CheckType.FAST_EAT);
|
||||||
} else {
|
} else {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
boolean noHack = true;
|
boolean noHack = true;
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
// Keep players from shooting an arrow at themselves in order to fly
|
// Keep players from shooting an arrow at themselves in order to fly
|
||||||
if (e.getDamager() instanceof Arrow) {
|
if (e.getDamager() instanceof Arrow) {
|
||||||
Arrow arrow = (Arrow) e.getDamager();
|
Arrow arrow = (Arrow) e.getDamager();
|
||||||
if (arrow.getShooter() instanceof Player && event.getEntity() == arrow.getShooter()) {
|
if (arrow.getShooter() instanceof Player && event.getEntity() == arrow.getShooter()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Utilities.hasArmorEnchantment(player, Enchantment.THORNS)) {
|
if (Utilities.hasArmorEnchantment(player, Enchantment.THORNS)) {
|
||||||
getBackend().logAnimation(player);
|
getBackend().logAnimation(player);
|
||||||
}
|
}
|
||||||
if (e.getDamager() instanceof Player) {
|
if (e.getDamager() instanceof Player) {
|
||||||
Player p = (Player) e.getDamager();
|
Player p = (Player) e.getDamager();
|
||||||
getBackend().logDamage(p, 1);
|
getBackend().logDamage(p, 1);
|
||||||
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
||||||
getBackend().logDamage(player, value);
|
getBackend().logDamage(player, value);
|
||||||
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
|
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
|
||||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||||
CheckResult result = getBackend().checkLongReachDamage(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
CheckResult result = getBackend().checkLongReachDamage(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), p, CheckType.LONG_REACH);
|
log(result.getMessage(), p, CheckType.LONG_REACH);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
||||||
getBackend().logDamage(player, 3);
|
getBackend().logDamage(player, 3);
|
||||||
} else {
|
} else {
|
||||||
getBackend().logDamage(player, 1);
|
getBackend().logDamage(player, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getDamager() instanceof Player) {
|
if (e.getDamager() instanceof Player) {
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
getBackend().logDamage(player, 1);
|
getBackend().logDamage(player, 1);
|
||||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
||||||
CheckResult result = getBackend().checkAutoTool(player);
|
CheckResult result = getBackend().checkAutoTool(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
||||||
CheckResult result = getBackend().checkSprintDamage(player);
|
CheckResult result = getBackend().checkSprintDamage(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
||||||
CheckResult result = getBackend().checkAnimation(player, event.getEntity());
|
CheckResult result = getBackend().checkAnimation(player, event.getEntity());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.NO_SWING);
|
log(result.getMessage(), player, CheckType.NO_SWING);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
||||||
CheckResult result = getBackend().checkSight(player, e.getEntity());
|
CheckResult result = getBackend().checkSight(player, e.getEntity());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (noHack) {
|
if (noHack) {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+139
-139
@@ -1,139 +1,139 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.manage.*;
|
import net.gravitydevelopment.anticheat.manage.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class EventListener implements Listener {
|
public class EventListener implements Listener {
|
||||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||||
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
||||||
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
||||||
private static final Backend BACKEND = AntiCheat.getManager().getBackend();
|
private static final Backend BACKEND = AntiCheat.getManager().getBackend();
|
||||||
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin();
|
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin();
|
||||||
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
||||||
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
||||||
|
|
||||||
public static void log(String message, Player player, CheckType type) {
|
public static void log(String message, Player player, CheckType type) {
|
||||||
User user = getUserManager().getUser(player.getName());
|
User user = getUserManager().getUser(player.getName());
|
||||||
if (user != null) { // npc
|
if (user != null) { // npc
|
||||||
logCheat(type, user);
|
logCheat(type, user);
|
||||||
if (user.increaseLevel(type) && message != null) {
|
if (user.increaseLevel(type) && message != null) {
|
||||||
AntiCheat.getManager().log(message);
|
AntiCheat.getManager().log(message);
|
||||||
}
|
}
|
||||||
removeDecrease(user);
|
removeDecrease(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logCheat(CheckType type, User user) {
|
private static void logCheat(CheckType type, User user) {
|
||||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||||
if (user != null && user.getName() != null) {
|
if (user != null && user.getName() != null) {
|
||||||
type.logUse(user);
|
type.logUse(user);
|
||||||
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
||||||
CONFIG.getEnterprise().database.logEvent(user, type);
|
CONFIG.getEnterprise().database.logEvent(user, type);
|
||||||
}
|
}
|
||||||
if (CONFIG.getConfig().fileLogLevel.getValue() == 2 && type.getUses(user.getName()) % 10 == 0) {
|
if (CONFIG.getConfig().fileLogLevel.getValue() == 2 && type.getUses(user.getName()) % 10 == 0) {
|
||||||
AntiCheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
AntiCheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCheck(CheckType type) {
|
public void resetCheck(CheckType type) {
|
||||||
USAGE_LIST.put(type, 0);
|
USAGE_LIST.put(type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCheats(CheckType type) {
|
public static int getCheats(CheckType type) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if (USAGE_LIST.get(type) != null) {
|
if (USAGE_LIST.get(type) != null) {
|
||||||
x = USAGE_LIST.get(type);
|
x = USAGE_LIST.get(type);
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeDecrease(User user) {
|
private static void removeDecrease(User user) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
// Ignore plugins that are creating NPCs with no names
|
// Ignore plugins that are creating NPCs with no names
|
||||||
if (user.getName() != null) {
|
if (user.getName() != null) {
|
||||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||||
x = DECREASE_LIST.get(user.getName());
|
x = DECREASE_LIST.get(user.getName());
|
||||||
x -= 2;
|
x -= 2;
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DECREASE_LIST.put(user.getName(), x);
|
DECREASE_LIST.put(user.getName(), x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void decrease(Player player) {
|
public static void decrease(Player player) {
|
||||||
User user = getUserManager().getUser(player.getName());
|
User user = getUserManager().getUser(player.getName());
|
||||||
// Ignore plugins that are creating NPCs with no names
|
// Ignore plugins that are creating NPCs with no names
|
||||||
if (user.getName() != null) {
|
if (user.getName() != null) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||||
x = DECREASE_LIST.get(user.getName());
|
x = DECREASE_LIST.get(user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 1;
|
x += 1;
|
||||||
DECREASE_LIST.put(user.getName(), x);
|
DECREASE_LIST.put(user.getName(), x);
|
||||||
|
|
||||||
if (x >= 10) {
|
if (x >= 10) {
|
||||||
user.decreaseLevel();
|
user.decreaseLevel();
|
||||||
DECREASE_LIST.put(user.getName(), 0);
|
DECREASE_LIST.put(user.getName(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckManager getCheckManager() {
|
public static CheckManager getCheckManager() {
|
||||||
return CHECK_MANAGER;
|
return CHECK_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnticheatManager getManager() {
|
public static AnticheatManager getManager() {
|
||||||
return AntiCheat.getManager();
|
return AntiCheat.getManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Backend getBackend() {
|
public static Backend getBackend() {
|
||||||
return BACKEND;
|
return BACKEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserManager getUserManager() {
|
public static UserManager getUserManager() {
|
||||||
return USER_MANAGER;
|
return USER_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AntiCheat getPlugin() {
|
public static AntiCheat getPlugin() {
|
||||||
return PLUGIN;
|
return PLUGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Configuration getConfig() {
|
public static Configuration getConfig() {
|
||||||
return CONFIG;
|
return CONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean silentMode() {
|
public static boolean silentMode() {
|
||||||
return CONFIG.getConfig().silentMode.getValue();
|
return CONFIG.getConfig().silentMode.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.util.CheckResult;
|
import net.gravitydevelopment.anticheat.util.CheckResult;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
+459
-459
@@ -1,459 +1,459 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.util.CheckResult;
|
import net.gravitydevelopment.anticheat.util.CheckResult;
|
||||||
import net.h31ix.anticheat.util.Distance;
|
import net.gravitydevelopment.anticheat.util.Distance;
|
||||||
import net.h31ix.anticheat.util.Permission;
|
import net.gravitydevelopment.anticheat.util.Permission;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
public class PlayerListener extends EventListener {
|
public class PlayerListener extends EventListener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockCommandSpam.getValue()) {
|
if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockCommandSpam.getValue()) {
|
||||||
CheckResult result = getBackend().checkSpam(player, event.getMessage());
|
CheckResult result = getBackend().checkSpam(player, event.getMessage());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
player.sendMessage(ChatColor.RED + result.getMessage());
|
player.sendMessage(ChatColor.RED + result.getMessage());
|
||||||
getBackend().processChatSpammer(player);
|
getBackend().processChatSpammer(player);
|
||||||
log(null, player, CheckType.SPAM);
|
log(null, player, CheckType.SPAM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||||
if (!event.isFlying()) {
|
if (!event.isFlying()) {
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||||
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
if (event.getEntity().getShooter() instanceof Player) {
|
if (event.getEntity().getShooter() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity().getShooter();
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
|
|
||||||
if (event.getEntity() instanceof Arrow) {
|
if (event.getEntity() instanceof Arrow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
||||||
CheckResult result = getBackend().checkProjectile(player);
|
CheckResult result = getBackend().checkProjectile(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
||||||
getBackend().logTeleport(event.getPlayer());
|
getBackend().logTeleport(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
||||||
getBackend().logTeleport(event.getPlayer());
|
getBackend().logTeleport(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||||
if (event.isSneaking()) {
|
if (event.isSneaking()) {
|
||||||
getBackend().logToggleSneak(event.getPlayer());
|
getBackend().logToggleSneak(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLY)) {
|
if (getCheckManager().willCheck(player, CheckType.FLY)) {
|
||||||
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
|
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
return; // don't log it lol.
|
return; // don't log it lol.
|
||||||
}
|
}
|
||||||
getBackend().logVelocity(player);
|
getBackend().logVelocity(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockChatSpam.getValue()) {
|
if (getCheckManager().willCheck(player, CheckType.SPAM) && getConfig().getConfig().blockChatSpam.getValue()) {
|
||||||
CheckResult result = getBackend().checkSpam(player, event.getMessage());
|
CheckResult result = getBackend().checkSpam(player, event.getMessage());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
if (!result.getMessage().equals("")) {
|
if (!result.getMessage().equals("")) {
|
||||||
player.sendMessage(ChatColor.RED + result.getMessage());
|
player.sendMessage(ChatColor.RED + result.getMessage());
|
||||||
}
|
}
|
||||||
getBackend().processChatSpammer(player);
|
getBackend().processChatSpammer(player);
|
||||||
log(null, player, CheckType.SPAM);
|
log(null, player, CheckType.SPAM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
getBackend().clearChatLevel(event.getPlayer());
|
getBackend().clearChatLevel(event.getPlayer());
|
||||||
getBackend().garbageClean(event.getPlayer());
|
getBackend().garbageClean(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
getBackend().garbageClean(event.getPlayer());
|
getBackend().garbageClean(event.getPlayer());
|
||||||
|
|
||||||
User user = getUserManager().getUser(event.getPlayer().getName());
|
User user = getUserManager().getUser(event.getPlayer().getName());
|
||||||
|
|
||||||
getConfig().getLevels().saveLevelFromUser(user);
|
getConfig().getLevels().saveLevelFromUser(user);
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!event.isSprinting()) {
|
if (!event.isSprinting()) {
|
||||||
getBackend().logEnterExit(player);
|
getBackend().logEnterExit(player);
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
||||||
CheckResult result = getBackend().checkSprintHungry(event);
|
CheckResult result = getBackend().checkSprintHungry(event);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.SPRINT);
|
log(result.getMessage(), player, CheckType.SPRINT);
|
||||||
} else {
|
} else {
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerInventory inv = player.getInventory();
|
PlayerInventory inv = player.getInventory();
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Material m = inv.getItemInHand().getType();
|
Material m = inv.getItemInHand().getType();
|
||||||
if (m == Material.BOW) {
|
if (m == Material.BOW) {
|
||||||
getBackend().logBowWindUp(player);
|
getBackend().logBowWindUp(player);
|
||||||
} else if (Utilities.isFood(m)) {
|
} else if (Utilities.isFood(m)) {
|
||||||
getBackend().logEatingStart(player);
|
getBackend().logEatingStart(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
||||||
CheckResult result = getBackend().checkFastDrop(player);
|
CheckResult result = getBackend().checkFastDrop(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||||
if (event.getBed().getType() != Material.BED) return;
|
if (event.getBed().getType() != Material.BED) return;
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||||
if (event.getBed().getType() != Material.BED) return;
|
if (event.getBed().getType() != Material.BED) return;
|
||||||
getBackend().logEnterExit(event.getPlayer());
|
getBackend().logEnterExit(event.getPlayer());
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (getCheckManager().willCheck(player, CheckType.FAST_ANIMATION)) {
|
if (getCheckManager().willCheck(player, CheckType.FAST_ANIMATION)) {
|
||||||
CheckResult result = getBackend().checkFastAnimation(player);
|
CheckResult result = getBackend().checkFastAnimation(player);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.FAST_ANIMATION);
|
log(result.getMessage(), player, CheckType.FAST_ANIMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String section = "\u00a7";
|
String section = "\u00a7";
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_FLY)) {
|
if (getCheckManager().willCheck(player, CheckType.ZOMBE_FLY)) {
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_CHEAT)) {
|
if (getCheckManager().willCheck(player, CheckType.ZOMBE_CHEAT)) {
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_NOCLIP)) {
|
if (getCheckManager().willCheck(player, CheckType.ZOMBE_NOCLIP)) {
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||||
}
|
}
|
||||||
|
|
||||||
getBackend().logJoin(player);
|
getBackend().logJoin(player);
|
||||||
|
|
||||||
User user = new User(player.getName());
|
User user = new User(player.getName());
|
||||||
user.setIsWaitingOnLevelSync(true);
|
user.setIsWaitingOnLevelSync(true);
|
||||||
getConfig().getLevels().loadLevelToUser(user);
|
getConfig().getLevels().loadLevelToUser(user);
|
||||||
getUserManager().addUser(user);
|
getUserManager().addUser(user);
|
||||||
|
|
||||||
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
||||||
for (Player p : player.getServer().getOnlinePlayers()) {
|
for (Player p : player.getServer().getOnlinePlayers()) {
|
||||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
if (!Permission.SYSTEM_SPY.get(p)) {
|
||||||
p.hidePlayer(player);
|
p.hidePlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
||||||
final Location from = event.getFrom();
|
final Location from = event.getFrom();
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
|
|
||||||
final Distance distance = new Distance(from, to);
|
final Distance distance = new Distance(from, to);
|
||||||
final double y = distance.getYDifference();
|
final double y = distance.getYDifference();
|
||||||
getBackend().logAscension(player, from.getY(), to.getY());
|
getBackend().logAscension(player, from.getY(), to.getY());
|
||||||
|
|
||||||
final User user = getUserManager().getUser(player.getName());
|
final User user = getUserManager().getUser(player.getName());
|
||||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||||
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) {
|
||||||
CheckResult result = getBackend().checkFreeze(player, from.getY(), to.getY());
|
CheckResult result = getBackend().checkFreeze(player, from.getY(), to.getY());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
log(result.getMessage(), player, CheckType.SPEED);
|
log(result.getMessage(), player, CheckType.SPEED);
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
player.kickPlayer("Freezing client");
|
player.kickPlayer("Freezing client");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
|
||||||
CheckResult result = getBackend().checkSprintStill(player, from, to);
|
CheckResult result = getBackend().checkSprintStill(player, from, to);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
log(result.getMessage(), player, CheckType.SPRINT);
|
log(result.getMessage(), player, CheckType.SPRINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !player.isFlying()) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !player.isFlying()) {
|
||||||
CheckResult result = getBackend().checkFlight(player, distance);
|
CheckResult result = getBackend().checkFlight(player, distance);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.FLY);
|
log(result.getMessage(), player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
||||||
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
int data = result.getData() > 3 ? 3 : result.getData();
|
int data = result.getData() > 3 ? 3 : result.getData();
|
||||||
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + data, event.getFrom().getZ());
|
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + data, event.getFrom().getZ());
|
||||||
if (newloc.getBlock().getTypeId() == 0) {
|
if (newloc.getBlock().getTypeId() == 0) {
|
||||||
event.setTo(newloc);
|
event.setTo(newloc);
|
||||||
} else {
|
} else {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
player.damage(3);
|
player.damage(3);
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.VCLIP);
|
log(result.getMessage(), player, CheckType.VCLIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) {
|
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) {
|
||||||
CheckResult result = getBackend().checkNoFall(player, y);
|
CheckResult result = getBackend().checkNoFall(player, y);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
player.damage(1); // I added this in here so the player would still receive damage.
|
player.damage(1); // I added this in here so the player would still receive damage.
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.NOFALL);
|
log(result.getMessage(), player, CheckType.NOFALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if (event.getTo() != event.getFrom()) {
|
if (event.getTo() != event.getFrom()) {
|
||||||
double x = distance.getXDifference();
|
double x = distance.getXDifference();
|
||||||
double z = distance.getZDifference();
|
double z = distance.getZDifference();
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) {
|
||||||
if (event.getFrom().getY() < event.getTo().getY()) {
|
if (event.getFrom().getY() < event.getTo().getY()) {
|
||||||
CheckResult result = getBackend().checkYSpeed(player, y);
|
CheckResult result = getBackend().checkYSpeed(player, y);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.SPEED);
|
log(result.getMessage(), player, CheckType.SPEED);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckResult result = getBackend().checkXZSpeed(player, x, z);
|
CheckResult result = getBackend().checkXZSpeed(player, x, z);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.SPEED);
|
log(result.getMessage(), player, CheckType.SPEED);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
/*if ((event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ())) {
|
/*if ((event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ())) {
|
||||||
result = backend.checkTimer(player);
|
result = backend.checkTimer(player);
|
||||||
if(result.failed()) {
|
if(result.failed()) {
|
||||||
if (!config.silentMode()) {
|
if (!config.silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log("tried to alter their timer.", player, CheckType.SPEED);
|
log("tried to alter their timer.", player, CheckType.SPEED);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||||
CheckResult result = getBackend().checkWaterWalk(player, x, y, z);
|
CheckResult result = getBackend().checkWaterWalk(player, x, y, z);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1, 0)));
|
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1, 0)));
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.WATER_WALK);
|
log(result.getMessage(), player, CheckType.WATER_WALK);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SNEAK)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.SNEAK)) {
|
||||||
CheckResult result = getBackend().checkSneak(player, x, z);
|
CheckResult result = getBackend().checkSneak(player, x, z);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
player.setSneaking(false);
|
player.setSneaking(false);
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.SNEAK);
|
log(result.getMessage(), player, CheckType.SNEAK);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
||||||
CheckResult result = getBackend().checkSpider(player, y);
|
CheckResult result = getBackend().checkSpider(player, y);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log(result.getMessage(), player, CheckType.SPIDER);
|
log(result.getMessage(), player, CheckType.SPIDER);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
user.setGoodLocation(event.getFrom());
|
user.setGoodLocation(event.getFrom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void checkFly(PlayerMoveEvent event) {
|
public void checkFly(PlayerMoveEvent event) {
|
||||||
// Check flight on highest to make sure other plugins have a chance to change the values first.
|
// Check flight on highest to make sure other plugins have a chance to change the values first.
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final User user = getUserManager().getUser(player.getName());
|
final User user = getUserManager().getUser(player.getName());
|
||||||
final Location from = event.getFrom();
|
final Location from = event.getFrom();
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
|
|
||||||
if (!user.checkTo(to.getX(), to.getY(), to.getZ())) {
|
if (!user.checkTo(to.getX(), to.getY(), to.getZ())) {
|
||||||
// The to value has been modified by another plugin
|
// The to value has been modified by another plugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getCheckManager().willCheck(player, CheckType.FLY) && !player.isFlying()) {
|
if (getCheckManager().willCheck(player, CheckType.FLY) && !player.isFlying()) {
|
||||||
CheckResult result1 = getBackend().checkYAxis(player, new Distance(from, to));
|
CheckResult result1 = getBackend().checkYAxis(player, new Distance(from, to));
|
||||||
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
||||||
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
||||||
if (!log.equals("")) {
|
if (!log.equals("")) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
log(log, player, CheckType.FLY);
|
log(log, player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+57
-57
@@ -1,57 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.event;
|
package net.gravitydevelopment.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
|
|
||||||
public class VehicleListener extends EventListener {
|
public class VehicleListener extends EventListener {
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||||
if (event.getEntered() instanceof Player) {
|
if (event.getEntered() instanceof Player) {
|
||||||
getBackend().logEnterExit((Player) event.getEntered());
|
getBackend().logEnterExit((Player) event.getEntered());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleExit(VehicleExitEvent event) {
|
public void onVehicleExit(VehicleExitEvent event) {
|
||||||
if (event.getExited() instanceof Player) {
|
if (event.getExited() instanceof Player) {
|
||||||
getBackend().logEnterExit((Player) event.getExited());
|
getBackend().logEnterExit((Player) event.getExited());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
|
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
|
||||||
getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
|
getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
|
||||||
}
|
}
|
||||||
|
|
||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+185
-185
@@ -1,185 +1,185 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.util.FileFormatter;
|
import net.gravitydevelopment.anticheat.util.FileFormatter;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.gravitydevelopment.anticheat.xray.XRayTracker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.logging.FileHandler;
|
import java.util.logging.FileHandler;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal hub for all managers.
|
* The internal hub for all managers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AnticheatManager {
|
public class AnticheatManager {
|
||||||
private static AntiCheat plugin = null;
|
private static AntiCheat plugin = null;
|
||||||
private static Configuration configuration;
|
private static Configuration configuration;
|
||||||
private static XRayTracker xrayTracker = null;
|
private static XRayTracker xrayTracker = null;
|
||||||
private static UserManager userManager = null;
|
private static UserManager userManager = null;
|
||||||
private static CheckManager checkManager = null;
|
private static CheckManager checkManager = null;
|
||||||
private static Backend backend = null;
|
private static Backend backend = null;
|
||||||
private final Logger fileLogger;
|
private final Logger fileLogger;
|
||||||
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
|
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
|
||||||
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
|
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
|
||||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||||
private static Handler fileHandler;
|
private static Handler fileHandler;
|
||||||
private static final int LOG_LEVEL_HIGH = 3;
|
private static final int LOG_LEVEL_HIGH = 3;
|
||||||
|
|
||||||
public AnticheatManager(AntiCheat instance, Logger logger) {
|
public AnticheatManager(AntiCheat instance, Logger logger) {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
// now load all the others!!!!!
|
// now load all the others!!!!!
|
||||||
fileLogger = Logger.getLogger("net.h31ix.anticheat.AntiCheat");
|
fileLogger = Logger.getLogger("net.gravitydevelopment.anticheat.AntiCheat");
|
||||||
configuration = new Configuration(plugin);
|
configuration = new Configuration(plugin);
|
||||||
xrayTracker = new XRayTracker();
|
xrayTracker = new XRayTracker();
|
||||||
userManager = new UserManager(configuration);
|
userManager = new UserManager(configuration);
|
||||||
checkManager = new CheckManager(this, configuration);
|
checkManager = new CheckManager(this, configuration);
|
||||||
backend = new Backend(this);
|
backend = new Backend(this);
|
||||||
try {
|
try {
|
||||||
File file = new File(plugin.getDataFolder(), "log");
|
File file = new File(plugin.getDataFolder(), "log");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
}
|
}
|
||||||
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
||||||
fileHandler.setFormatter(new FileFormatter());
|
fileHandler.setFormatter(new FileFormatter());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, null, ex);
|
logger.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
fileLogger.setUseParentHandlers(false);
|
fileLogger.setUseParentHandlers(false);
|
||||||
fileLogger.addHandler(fileHandler);
|
fileLogger.addHandler(fileHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
log(message, 0);
|
log(message, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message, int i) {
|
public void log(String message, int i) {
|
||||||
if (i != 1 && getConfiguration().getConfig().logToConsole.getValue()) {
|
if (i != 1 && getConfiguration().getConfig().logToConsole.getValue()) {
|
||||||
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message);
|
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message);
|
||||||
}
|
}
|
||||||
if (i == 0 && getConfiguration().getConfig().fileLogLevel.getValue() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
if (i == 0 && getConfiguration().getConfig().fileLogLevel.getValue() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
||||||
{
|
{
|
||||||
fileLog(message);
|
fileLog(message);
|
||||||
} else if (getConfiguration().getConfig().fileLogLevel.getValue() != 0) { // alert
|
} else if (getConfiguration().getConfig().fileLogLevel.getValue() != 0) { // alert
|
||||||
fileLog(message);
|
fileLog(message);
|
||||||
}
|
}
|
||||||
logs.add(ChatColor.stripColor(message));
|
logs.add(ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fileLog(String message) {
|
public void fileLog(String message) {
|
||||||
fileLogger.info(message);
|
fileLogger.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getLastLogs() {
|
public List<String> getLastLogs() {
|
||||||
List<String> log = new CopyOnWriteArrayList<String>();
|
List<String> log = new CopyOnWriteArrayList<String>();
|
||||||
if (logs.size() < 30) {
|
if (logs.size() < 30) {
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
for (int i = logs.size() - 1; i >= 0; i--) {
|
for (int i = logs.size() - 1; i >= 0; i--) {
|
||||||
log.add(logs.get(i));
|
log.add(logs.get(i));
|
||||||
}
|
}
|
||||||
logs.clear();
|
logs.clear();
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEvent(String e, RegisteredListener[] arr) {
|
public void addEvent(String e, RegisteredListener[] arr) {
|
||||||
if (!configuration.getConfig().eventChains.getValue())
|
if (!configuration.getConfig().eventChains.getValue())
|
||||||
return;
|
return;
|
||||||
if (!eventcache.containsKey(e) || eventcache.get(e) > 30000L) {
|
if (!eventcache.containsKey(e) || eventcache.get(e) > 30000L) {
|
||||||
eventchains.put(e, arr);
|
eventchains.put(e, arr);
|
||||||
eventcache.put(e, System.currentTimeMillis());
|
eventcache.put(e, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEventChainReport() {
|
public String getEventChainReport() {
|
||||||
String gen = "";
|
String gen = "";
|
||||||
if (!configuration.getConfig().eventChains.getValue()) {
|
if (!configuration.getConfig().eventChains.getValue()) {
|
||||||
return "Event Chains is disabled by the configuration." + '\n';
|
return "Event Chains is disabled by the configuration." + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventchains.entrySet().size() == 0) {
|
if (eventchains.entrySet().size() == 0) {
|
||||||
return "No event chains found." + '\n';
|
return "No event chains found." + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, RegisteredListener[]> e : eventchains.entrySet()) {
|
for (Entry<String, RegisteredListener[]> e : eventchains.entrySet()) {
|
||||||
String toadd = "";
|
String toadd = "";
|
||||||
String ename = e.getKey();
|
String ename = e.getKey();
|
||||||
|
|
||||||
toadd += ename + ":" + '\n';
|
toadd += ename + ":" + '\n';
|
||||||
|
|
||||||
RegisteredListener[] reg = e.getValue();
|
RegisteredListener[] reg = e.getValue();
|
||||||
for (RegisteredListener plug : reg) {
|
for (RegisteredListener plug : reg) {
|
||||||
String pluginname = plug.getPlugin().getName();
|
String pluginname = plug.getPlugin().getName();
|
||||||
if (pluginname.equals("AntiCheat"))
|
if (pluginname.equals("AntiCheat"))
|
||||||
pluginname = "self";
|
pluginname = "self";
|
||||||
|
|
||||||
toadd += "- " + pluginname + '\n';
|
toadd += "- " + pluginname + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
gen += toadd + '\n';
|
gen += toadd + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
return gen;
|
return gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AntiCheat getPlugin() {
|
public AntiCheat getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getConfiguration() {
|
public Configuration getConfiguration() {
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XRayTracker getXRayTracker() {
|
public XRayTracker getXRayTracker() {
|
||||||
return xrayTracker;
|
return xrayTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserManager getUserManager() {
|
public UserManager getUserManager() {
|
||||||
return userManager;
|
return userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckManager getCheckManager() {
|
public CheckManager getCheckManager() {
|
||||||
return checkManager;
|
return checkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Backend getBackend() {
|
public Backend getBackend() {
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() {
|
public static void close() {
|
||||||
fileHandler.close();
|
fileHandler.close();
|
||||||
|
|
||||||
if (configuration.getConfig().enterprise.getValue()) {
|
if (configuration.getConfig().enterprise.getValue()) {
|
||||||
configuration.getEnterprise().database.shutdown();
|
configuration.getEnterprise().database.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1079
-1079
File diff suppressed because it is too large.
Load diff
+211
-211
@@ -1,211 +1,211 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p/>
|
* <p/>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CheckManager {
|
public class CheckManager {
|
||||||
private AnticheatManager manager = null;
|
private AnticheatManager manager = null;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||||
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
|
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
|
||||||
private static int disabled = 0;
|
private static int disabled = 0;
|
||||||
private static int exempt = 0;
|
private static int exempt = 0;
|
||||||
|
|
||||||
public CheckManager(AnticheatManager instance, Configuration config) {
|
public CheckManager(AnticheatManager instance, Configuration config) {
|
||||||
manager = instance;
|
manager = instance;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a check on
|
* Turn a check on
|
||||||
*
|
*
|
||||||
* @param type The CheckType to enable
|
* @param type The CheckType to enable
|
||||||
*/
|
*/
|
||||||
public void activateCheck(CheckType type) {
|
public void activateCheck(CheckType type) {
|
||||||
if (isActive(type)) {
|
if (isActive(type)) {
|
||||||
manager.log("The " + type.toString() + " check was activated.");
|
manager.log("The " + type.toString() + " check was activated.");
|
||||||
checkIgnoreList.remove(type);
|
checkIgnoreList.remove(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a check off
|
* Turn a check off
|
||||||
*
|
*
|
||||||
* @param type The CheckType to disable
|
* @param type The CheckType to disable
|
||||||
*/
|
*/
|
||||||
public void deactivateCheck(CheckType type) {
|
public void deactivateCheck(CheckType type) {
|
||||||
if (!isActive(type)) {
|
if (!isActive(type)) {
|
||||||
manager.log("The " + type.toString() + " check was deactivated.");
|
manager.log("The " + type.toString() + " check was deactivated.");
|
||||||
checkIgnoreList.add(type);
|
checkIgnoreList.add(type);
|
||||||
disabled++;
|
disabled++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a check is enabled
|
* Determine whether a check is enabled
|
||||||
*
|
*
|
||||||
* @param type The CheckType to check
|
* @param type The CheckType to check
|
||||||
* @return true if the check is active
|
* @return true if the check is active
|
||||||
*/
|
*/
|
||||||
public boolean isActive(CheckType type) {
|
public boolean isActive(CheckType type) {
|
||||||
return !checkIgnoreList.contains(type);
|
return !checkIgnoreList.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exempt a player from a check
|
* Exempt a player from a check
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @param type The check
|
* @param type The check
|
||||||
*/
|
*/
|
||||||
public void exemptPlayer(Player player, CheckType type) {
|
public void exemptPlayer(Player player, CheckType type) {
|
||||||
if (!isExempt(player, type)) {
|
if (!isExempt(player, type)) {
|
||||||
if (!exemptList.containsKey(player.getName())) {
|
if (!exemptList.containsKey(player.getName())) {
|
||||||
exemptList.put(player.getName(), new ArrayList<CheckType>());
|
exemptList.put(player.getName(), new ArrayList<CheckType>());
|
||||||
}
|
}
|
||||||
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
||||||
exemptList.get(player.getName()).add(type);
|
exemptList.get(player.getName()).add(type);
|
||||||
exempt++;
|
exempt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unexempt a player from a check
|
* Unexempt a player from a check
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @param type The check
|
* @param type The check
|
||||||
*/
|
*/
|
||||||
public void unexemptPlayer(Player player, CheckType type) {
|
public void unexemptPlayer(Player player, CheckType type) {
|
||||||
if (isExempt(player, type)) {
|
if (isExempt(player, type)) {
|
||||||
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
||||||
exemptList.get(player.getName()).remove(type);
|
exemptList.get(player.getName()).remove(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is exempt from a check
|
* Determine whether a player is exempt from a check
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @param type The check
|
* @param type The check
|
||||||
*/
|
*/
|
||||||
public boolean isExempt(Player player, CheckType type) {
|
public boolean isExempt(Player player, CheckType type) {
|
||||||
return exemptList.containsKey(player.getName()) ? exemptList.get(player.getName()).contains(type) : false;
|
return exemptList.containsKey(player.getName()) ? exemptList.get(player.getName()).contains(type) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is exempt from all checks from op status
|
* Determine whether a player is exempt from all checks from op status
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
*/
|
*/
|
||||||
public boolean isOpExempt(Player player) {
|
public boolean isOpExempt(Player player) {
|
||||||
return (this.manager.getConfiguration().getConfig().exemptOp.getValue() && player.isOp());
|
return (this.manager.getConfiguration().getConfig().exemptOp.getValue() && player.isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player should be checked in their world
|
* Determine whether a player should be checked in their world
|
||||||
*
|
*
|
||||||
* @param player The player
|
* @param player The player
|
||||||
* @return true if the player's world is enabled
|
* @return true if the player's world is enabled
|
||||||
*/
|
*/
|
||||||
public boolean checkInWorld(Player player) {
|
public boolean checkInWorld(Player player) {
|
||||||
return !config.getConfig().exemptedWorlds.getValue().contains(player.getWorld().getName());
|
return !config.getConfig().exemptedWorlds.getValue().contains(player.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a quick version of the "willCheck" method, using the other non-check-specific methods beforehand
|
* Run a quick version of the "willCheck" method, using the other non-check-specific methods beforehand
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @param type The check being run
|
* @param type The check being run
|
||||||
* @return true if the check should run
|
* @return true if the check should run
|
||||||
*/
|
*/
|
||||||
public boolean willCheckQuick(Player player, CheckType type) {
|
public boolean willCheckQuick(Player player, CheckType type) {
|
||||||
return
|
return
|
||||||
isActive(type)
|
isActive(type)
|
||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !type.checkPermission(player);
|
&& !type.checkPermission(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a check should run on a player
|
* Determine whether a check should run on a player
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @param type The check being run
|
* @param type The check being run
|
||||||
* @return true if the check should run
|
* @return true if the check should run
|
||||||
*/
|
*/
|
||||||
public boolean willCheck(Player player, CheckType type) {
|
public boolean willCheck(Player player, CheckType type) {
|
||||||
boolean check = isActive(type)
|
boolean check = isActive(type)
|
||||||
&& checkInWorld(player)
|
&& checkInWorld(player)
|
||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !type.checkPermission(player)
|
&& !type.checkPermission(player)
|
||||||
&& !isOpExempt(player);
|
&& !isOpExempt(player);
|
||||||
AntiCheat.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
AntiCheat.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is actually online; not an NPC
|
* Determine whether a player is actually online; not an NPC
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @return true if the player is a real person
|
* @return true if the player is a real person
|
||||||
*/
|
*/
|
||||||
public boolean isOnline(Player player) {
|
public boolean isOnline(Player player) {
|
||||||
// Check if the player is on the user list, e.g. is not an NPC
|
// Check if the player is on the user list, e.g. is not an NPC
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (p.getName().equals(player.getName())) {
|
if (p.getName().equals(player.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of exempt players
|
* Get the number of exempt players
|
||||||
*
|
*
|
||||||
* @return exempt players
|
* @return exempt players
|
||||||
*/
|
*/
|
||||||
public int getExempt() {
|
public int getExempt() {
|
||||||
int x = exempt;
|
int x = exempt;
|
||||||
exempt = 0;
|
exempt = 0;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of disabled checks
|
* Get the number of disabled checks
|
||||||
*
|
*
|
||||||
* @return disabled checks
|
* @return disabled checks
|
||||||
*/
|
*/
|
||||||
public int getDisabled() {
|
public int getDisabled() {
|
||||||
int x = disabled;
|
int x = disabled;
|
||||||
disabled = 0;
|
disabled = 0;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+125
-125
@@ -1,125 +1,125 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import net.h31ix.anticheat.api.CheckFailEvent;
|
import net.gravitydevelopment.anticheat.api.CheckFailEvent;
|
||||||
import net.h31ix.anticheat.util.Permission;
|
import net.gravitydevelopment.anticheat.util.Permission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p/>
|
* <p/>
|
||||||
* All the types of checks and their corresponding permission nodes.
|
* All the types of checks and their corresponding permission nodes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum CheckType {
|
public enum CheckType {
|
||||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
||||||
FLY(Permission.CHECK_FLY),
|
FLY(Permission.CHECK_FLY),
|
||||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
WATER_WALK(Permission.CHECK_WATERWALK),
|
||||||
NO_SWING(Permission.CHECK_NOSWING),
|
NO_SWING(Permission.CHECK_NOSWING),
|
||||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
||||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
||||||
SPAM(Permission.CHECK_SPAM),
|
SPAM(Permission.CHECK_SPAM),
|
||||||
SPRINT(Permission.CHECK_SPRINT),
|
SPRINT(Permission.CHECK_SPRINT),
|
||||||
SNEAK(Permission.CHECK_SNEAK),
|
SNEAK(Permission.CHECK_SNEAK),
|
||||||
SPEED(Permission.CHECK_SPEED),
|
SPEED(Permission.CHECK_SPEED),
|
||||||
VCLIP(Permission.CHECK_VCLIP),
|
VCLIP(Permission.CHECK_VCLIP),
|
||||||
SPIDER(Permission.CHECK_SPIDER),
|
SPIDER(Permission.CHECK_SPIDER),
|
||||||
NOFALL(Permission.CHECK_NOFALL),
|
NOFALL(Permission.CHECK_NOFALL),
|
||||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||||
XRAY(Permission.CHECK_XRAY),
|
XRAY(Permission.CHECK_XRAY),
|
||||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
FAST_ANIMATION(Permission.CHECK_FASTANIMATION),
|
FAST_ANIMATION(Permission.CHECK_FASTANIMATION),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
||||||
|
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a CheckType
|
* Initialize a CheckType
|
||||||
*
|
*
|
||||||
* @param perm Permission that applies to this check
|
* @param perm Permission that applies to this check
|
||||||
*/
|
*/
|
||||||
private CheckType(Permission perm) {
|
private CheckType(Permission perm) {
|
||||||
this.permission = perm;
|
this.permission = perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player has permission to bypass this check
|
* Determine whether a player has permission to bypass this check
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player Player to check
|
||||||
* @return true if the player can bypass
|
* @return true if the player can bypass
|
||||||
*/
|
*/
|
||||||
public boolean checkPermission(Player player) {
|
public boolean checkPermission(Player player) {
|
||||||
return permission.get(player);
|
return permission.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log the failure of this check
|
* Log the failure of this check
|
||||||
*
|
*
|
||||||
* @param user User who failed the check
|
* @param user User who failed the check
|
||||||
*/
|
*/
|
||||||
public void logUse(User user) {
|
public void logUse(User user) {
|
||||||
int amount = level.get(user.getName()) == null ? 1 : level.get(user.getName()) + 1;
|
int amount = level.get(user.getName()) == null ? 1 : level.get(user.getName()) + 1;
|
||||||
level.put(user.getName(), amount);
|
level.put(user.getName(), amount);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new CheckFailEvent(user, this));
|
Bukkit.getServer().getPluginManager().callEvent(new CheckFailEvent(user, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear failure history of this check for a user
|
* Clear failure history of this check for a user
|
||||||
*
|
*
|
||||||
* @param name User's name to clear
|
* @param name User's name to clear
|
||||||
*/
|
*/
|
||||||
public void clearUse(String name) {
|
public void clearUse(String name) {
|
||||||
level.put(name, 0);
|
level.put(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get how many times a user has failed this check
|
* Get how many times a user has failed this check
|
||||||
*
|
*
|
||||||
* @param name User's name
|
* @param name User's name
|
||||||
* @return number of times failed
|
* @return number of times failed
|
||||||
*/
|
*/
|
||||||
public int getUses(String name) {
|
public int getUses(String name) {
|
||||||
return level.get(name) != null ? level.get(name) : 0;
|
return level.get(name) != null ? level.get(name) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the reference name of a check
|
* Get the reference name of a check
|
||||||
*
|
*
|
||||||
* @param type Type of check
|
* @param type Type of check
|
||||||
* @return reference name
|
* @return reference name
|
||||||
*/
|
*/
|
||||||
public static String getName(CheckType type) {
|
public static String getName(CheckType type) {
|
||||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||||
chars[0] = Character.toUpperCase(chars[0]);
|
chars[0] = Character.toUpperCase(chars[0]);
|
||||||
return new String(chars);
|
return new String(chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.*;
|
import com.comphenix.protocol.events.*;
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
|
|
||||||
public class PacketManager {
|
public class PacketManager {
|
||||||
|
|
||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.gravitydevelopment.anticheat.util.Level;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import net.h31ix.anticheat.util.rule.Rule;
|
import net.gravitydevelopment.anticheat.util.rule.Rule;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class User {
|
public class User {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int id;
|
private final int id;
|
||||||
private int level = 0;
|
private int level = 0;
|
||||||
private Location goodLocation;
|
private Location goodLocation;
|
||||||
private List<ItemStack> inventorySnapshot = null;
|
private List<ItemStack> inventorySnapshot = null;
|
||||||
private Configuration config = AntiCheat.getManager().getConfiguration();
|
private Configuration config = AntiCheat.getManager().getConfiguration();
|
||||||
private int toX, toY, toZ;
|
private int toX, toY, toZ;
|
||||||
private String[] messages = new String[2];
|
private String[] messages = new String[2];
|
||||||
private Long[] messageTimes = new Long[2];
|
private Long[] messageTimes = new Long[2];
|
||||||
|
|
||||||
private boolean isWaitingOnLevelSync;
|
private boolean isWaitingOnLevelSync;
|
||||||
private Timestamp levelSyncTimestamp;
|
private Timestamp levelSyncTimestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize an AntiCheat user
|
* Initialize an AntiCheat user
|
||||||
*
|
*
|
||||||
* @param name Player's name
|
* @param name Player's name
|
||||||
*/
|
*/
|
||||||
public User(String name) {
|
public User(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's name
|
* Get the player's name
|
||||||
*
|
*
|
||||||
* @return Player name
|
* @return Player name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's entity ID
|
* Get the player's entity ID
|
||||||
*
|
*
|
||||||
* @return Entity id
|
* @return Entity id
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Bukkit player
|
* Get the Bukkit player
|
||||||
*
|
*
|
||||||
* @return Player
|
* @return Player
|
||||||
*/
|
*/
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return Bukkit.getPlayer(name);
|
return Bukkit.getPlayer(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user's level value
|
* Get the user's level value
|
||||||
*
|
*
|
||||||
* @return level
|
* @return level
|
||||||
*/
|
*/
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Level getNamedLevel() {
|
public Level getNamedLevel() {
|
||||||
List<Level> levels = config.getEvents().getLevels();
|
List<Level> levels = config.getEvents().getLevels();
|
||||||
for (int i = 0; i < levels.size(); i++) {
|
for (int i = 0; i < levels.size(); i++) {
|
||||||
if (i == 0 && level < levels.get(i).getValue()) break;
|
if (i == 0 && level < levels.get(i).getValue()) break;
|
||||||
else if (i == levels.size() - 1) return levels.get(i);
|
else if (i == levels.size() - 1) return levels.get(i);
|
||||||
else if (level >= levels.get(i).getValue() && level < levels.get(i + 1).getValue()) return levels.get(i);
|
else if (level >= levels.get(i).getValue() && level < levels.get(i + 1).getValue()) return levels.get(i);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increase the player's level (from failing a check)
|
* Increase the player's level (from failing a check)
|
||||||
*
|
*
|
||||||
* @param type The check failed
|
* @param type The check failed
|
||||||
* @return true if the level was increased
|
* @return true if the level was increased
|
||||||
*/
|
*/
|
||||||
public boolean increaseLevel(CheckType type) {
|
public boolean increaseLevel(CheckType type) {
|
||||||
if (getPlayer() != null && getPlayer().isOnline()) {
|
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||||
if (silentMode() && type.getUses(name) % 4 != 0) {
|
if (silentMode() && type.getUses(name) % 4 != 0) {
|
||||||
// Prevent silent mode from increasing the level way too fast
|
// Prevent silent mode from increasing the level way too fast
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (level < config.getEvents().getHighestLevel()) {
|
if (level < config.getEvents().getHighestLevel()) {
|
||||||
level++;
|
level++;
|
||||||
|
|
||||||
// Check levels
|
// Check levels
|
||||||
for (Level l : getLevels()) {
|
for (Level l : getLevels()) {
|
||||||
if (l.getValue() == level) {
|
if (l.getValue() == level) {
|
||||||
AntiCheat.getManager().getUserManager().alert(this, l, type);
|
AntiCheat.getManager().getUserManager().alert(this, l, type);
|
||||||
if (l.getValue() == config.getEvents().getHighestLevel()) {
|
if (l.getValue() == config.getEvents().getHighestLevel()) {
|
||||||
level = l.getValue() - 10;
|
level = l.getValue() - 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute rules
|
// Execute rules
|
||||||
for (Rule rule : config.getRules().getRules()) {
|
for (Rule rule : config.getRules().getRules()) {
|
||||||
rule.check(this, type);
|
rule.check(this, type);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrease the player's level by one value
|
* Decrease the player's level by one value
|
||||||
*/
|
*/
|
||||||
public void decreaseLevel() {
|
public void decreaseLevel() {
|
||||||
level = level != 0 ? level - 1 : 0;
|
level = level != 0 ? level - 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the users level to a specific value. Must be 0 < level < config-defined highest level
|
* Set the users level to a specific value. Must be 0 < level < config-defined highest level
|
||||||
*
|
*
|
||||||
* @param level level to set
|
* @param level level to set
|
||||||
* @return true if the level was valid and set properly
|
* @return true if the level was valid and set properly
|
||||||
*/
|
*/
|
||||||
public boolean setLevel(int level) {
|
public boolean setLevel(int level) {
|
||||||
isWaitingOnLevelSync = false;
|
isWaitingOnLevelSync = false;
|
||||||
if (level >= 0) {
|
if (level >= 0) {
|
||||||
if (level <= config.getEvents().getHighestLevel()) {
|
if (level <= config.getEvents().getHighestLevel()) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.level = config.getEvents().getHighestLevel();
|
this.level = config.getEvents().getHighestLevel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the user's level to zero and clear all check failures
|
* Reset the user's level to zero and clear all check failures
|
||||||
*/
|
*/
|
||||||
public void resetLevel() {
|
public void resetLevel() {
|
||||||
level = 0;
|
level = 0;
|
||||||
for (CheckType type : CheckType.values()) {
|
for (CheckType type : CheckType.values()) {
|
||||||
type.clearUse(name);
|
type.clearUse(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last known valid location of the player for use in resetting
|
* Get the last known valid location of the player for use in resetting
|
||||||
*
|
*
|
||||||
* @param location default value to be returned if no known good location exists
|
* @param location default value to be returned if no known good location exists
|
||||||
* @return last known valid location
|
* @return last known valid location
|
||||||
*/
|
*/
|
||||||
public Location getGoodLocation(Location location) {
|
public Location getGoodLocation(Location location) {
|
||||||
if (goodLocation == null) {
|
if (goodLocation == null) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
return goodLocation;
|
return goodLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the last known valid location of the player
|
* Set the last known valid location of the player
|
||||||
*
|
*
|
||||||
* @param location location to be set
|
* @param location location to be set
|
||||||
* @return true if the location was valid and set properly
|
* @return true if the location was valid and set properly
|
||||||
*/
|
*/
|
||||||
public boolean setGoodLocation(Location location) {
|
public boolean setGoodLocation(Location location) {
|
||||||
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
|
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
goodLocation = location;
|
goodLocation = location;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a copy of the player's inventory, for use in resetting
|
* Store a copy of the player's inventory, for use in resetting
|
||||||
*
|
*
|
||||||
* @param is ItemStack list to store
|
* @param is ItemStack list to store
|
||||||
*/
|
*/
|
||||||
public void setInventorySnapshot(ItemStack[] is) {
|
public void setInventorySnapshot(ItemStack[] is) {
|
||||||
inventorySnapshot = new ArrayList<ItemStack>();
|
inventorySnapshot = new ArrayList<ItemStack>();
|
||||||
for (int i = 0; i < is.length; i++) {
|
for (int i = 0; i < is.length; i++) {
|
||||||
if (is[i] != null) {
|
if (is[i] != null) {
|
||||||
inventorySnapshot.add(is[i].clone());
|
inventorySnapshot.add(is[i].clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the current inventory snapshot
|
* Remove the current inventory snapshot
|
||||||
*/
|
*/
|
||||||
public void removeInventorySnapshot() {
|
public void removeInventorySnapshot() {
|
||||||
inventorySnapshot = null;
|
inventorySnapshot = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore the player's inventory with the current inventory snapshot
|
* Restore the player's inventory with the current inventory snapshot
|
||||||
*
|
*
|
||||||
* @param inventory Player's inventory
|
* @param inventory Player's inventory
|
||||||
*/
|
*/
|
||||||
public void restoreInventory(Inventory inventory) {
|
public void restoreInventory(Inventory inventory) {
|
||||||
if (inventorySnapshot != null) {
|
if (inventorySnapshot != null) {
|
||||||
inventory.clear();
|
inventory.clear();
|
||||||
for (ItemStack is : inventorySnapshot) {
|
for (ItemStack is : inventorySnapshot) {
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
inventory.addItem(is);
|
inventory.addItem(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player's to location
|
* Set the player's to location
|
||||||
*
|
*
|
||||||
* @param x X value
|
* @param x X value
|
||||||
* @param y Y value
|
* @param y Y value
|
||||||
* @param z Z value
|
* @param z Z value
|
||||||
*/
|
*/
|
||||||
public void setTo(double x, double y, double z) {
|
public void setTo(double x, double y, double z) {
|
||||||
toX = (int) x;
|
toX = (int) x;
|
||||||
toY = (int) y;
|
toY = (int) y;
|
||||||
toZ = (int) z;
|
toZ = (int) z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given to value is the same as the stored value
|
* Check if a given to value is the same as the stored value
|
||||||
*
|
*
|
||||||
* @param x X value
|
* @param x X value
|
||||||
* @param y Y value
|
* @param y Y value
|
||||||
* @param z Z value
|
* @param z Z value
|
||||||
* @return true if coordinates are all equal
|
* @return true if coordinates are all equal
|
||||||
*/
|
*/
|
||||||
public boolean checkTo(double x, double y, double z) {
|
public boolean checkTo(double x, double y, double z) {
|
||||||
return (int) x == toX && (int) y == toY && (int) z == toZ;
|
return (int) x == toX && (int) y == toY && (int) z == toZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a player's chat message
|
* Log a player's chat message
|
||||||
*
|
*
|
||||||
* @param message Message to log
|
* @param message Message to log
|
||||||
*/
|
*/
|
||||||
public void addMessage(String message) {
|
public void addMessage(String message) {
|
||||||
messages[1] = messages[0];
|
messages[1] = messages[0];
|
||||||
messages[0] = message;
|
messages[0] = message;
|
||||||
|
|
||||||
messageTimes[1] = messageTimes[0];
|
messageTimes[1] = messageTimes[0];
|
||||||
messageTimes[0] = System.currentTimeMillis();
|
messageTimes[0] = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a stored chat message
|
* Get a stored chat message
|
||||||
*
|
*
|
||||||
* @param index Index of the chat in storage
|
* @param index Index of the chat in storage
|
||||||
* @return the message
|
* @return the message
|
||||||
*/
|
*/
|
||||||
public String getMessage(int index) {
|
public String getMessage(int index) {
|
||||||
return messages[index];
|
return messages[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time a message in storage was sent
|
* Get the time a message in storage was sent
|
||||||
*
|
*
|
||||||
* @param index Index of the chat in storage
|
* @param index Index of the chat in storage
|
||||||
* @return time the message was sent
|
* @return time the message was sent
|
||||||
*/
|
*/
|
||||||
public Long getMessageTime(int index) {
|
public Long getMessageTime(int index) {
|
||||||
return messageTimes[index];
|
return messageTimes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all stored messages
|
* Clear all stored messages
|
||||||
*/
|
*/
|
||||||
public void clearMessages() {
|
public void clearMessages() {
|
||||||
messages = new String[2];
|
messages = new String[2];
|
||||||
messageTimes = new Long[2];
|
messageTimes = new Long[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time the very last stored message was sent
|
* Get the time the very last stored message was sent
|
||||||
*
|
*
|
||||||
* @return the last message's time
|
* @return the last message's time
|
||||||
*/
|
*/
|
||||||
public Long getLastMessageTime() {
|
public Long getLastMessageTime() {
|
||||||
return getMessageTime(0) == null ? -1 : getMessageTime(0);
|
return getMessageTime(0) == null ? -1 : getMessageTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Level> getLevels() {
|
private List<Level> getLevels() {
|
||||||
return config.getEvents().getLevels();
|
return config.getEvents().getLevels();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean silentMode() {
|
private boolean silentMode() {
|
||||||
return config.getConfig().silentMode.getValue();
|
return config.getConfig().silentMode.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsWaitingOnLevelSync(boolean b) {
|
public void setIsWaitingOnLevelSync(boolean b) {
|
||||||
this.isWaitingOnLevelSync = b;
|
this.isWaitingOnLevelSync = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWaitingOnLevelSync() {
|
public boolean isWaitingOnLevelSync() {
|
||||||
return isWaitingOnLevelSync;
|
return isWaitingOnLevelSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevelSyncTimestamp(Timestamp timestamp) {
|
public void setLevelSyncTimestamp(Timestamp timestamp) {
|
||||||
levelSyncTimestamp = timestamp;
|
levelSyncTimestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getLevelSyncTimestamp() {
|
public Timestamp getLevelSyncTimestamp() {
|
||||||
return levelSyncTimestamp;
|
return levelSyncTimestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+229
-229
@@ -1,229 +1,229 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.gravitydevelopment.anticheat.manage;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.gravitydevelopment.anticheat.util.Level;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UserManager {
|
public class UserManager {
|
||||||
private List<User> users = new ArrayList<User>();
|
private List<User> users = new ArrayList<User>();
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
private static final ChatColor GOLD = ChatColor.GOLD;
|
||||||
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
private static final ChatColor RED = ChatColor.RED;
|
||||||
private static List<String> alert;
|
private static List<String> alert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the user manager with a given configuration
|
* Initialize the user manager with a given configuration
|
||||||
*
|
*
|
||||||
* @param conf Configuration to use
|
* @param conf Configuration to use
|
||||||
*/
|
*/
|
||||||
public UserManager(Configuration conf) {
|
public UserManager(Configuration conf) {
|
||||||
config = conf;
|
config = conf;
|
||||||
alert = config.getLang().alert.getValue();
|
alert = config.getLang().alert.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user with the given name
|
* Get a user with the given name
|
||||||
*
|
*
|
||||||
* @param name Name
|
* @param name Name
|
||||||
* @return User with name
|
* @return User with name
|
||||||
*/
|
*/
|
||||||
public User getUser(String name) {
|
public User getUser(String name) {
|
||||||
for (User user : users) {
|
for (User user : users) {
|
||||||
if (user.getName().equalsIgnoreCase(name)) {
|
if (user.getName().equalsIgnoreCase(name)) {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise try to load them
|
// Otherwise try to load them
|
||||||
User user = new User(name);
|
User user = new User(name);
|
||||||
user.setIsWaitingOnLevelSync(true);
|
user.setIsWaitingOnLevelSync(true);
|
||||||
config.getLevels().loadLevelToUser(user);
|
config.getLevels().loadLevelToUser(user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all users
|
* Get all users
|
||||||
*
|
*
|
||||||
* @return List of users
|
* @return List of users
|
||||||
*/
|
*/
|
||||||
public List<User> getUsers() {
|
public List<User> getUsers() {
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a user to the list
|
* Add a user to the list
|
||||||
*
|
*
|
||||||
* @param user User to add
|
* @param user User to add
|
||||||
*/
|
*/
|
||||||
public void addUser(User user) {
|
public void addUser(User user) {
|
||||||
users.add(user);
|
users.add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a user from the list
|
* Remove a user from the list
|
||||||
*
|
*
|
||||||
* @param user User to remove
|
* @param user User to remove
|
||||||
*/
|
*/
|
||||||
public void remove(User user) {
|
public void remove(User user) {
|
||||||
users.remove(user);
|
users.remove(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a user's level
|
* Save a user's level
|
||||||
*
|
*
|
||||||
* @param user User to save
|
* @param user User to save
|
||||||
*/
|
*/
|
||||||
public void saveLevel(User user) {
|
public void saveLevel(User user) {
|
||||||
config.getLevels().saveLevelFromUser(user);
|
config.getLevels().saveLevelFromUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user's level, or 0 if the player isn't found
|
* Get a user's level, or 0 if the player isn't found
|
||||||
*
|
*
|
||||||
* @param name Name of the player
|
* @param name Name of the player
|
||||||
* @return player level
|
* @return player level
|
||||||
*/
|
*/
|
||||||
public int safeGetLevel(String name) {
|
public int safeGetLevel(String name) {
|
||||||
User user = getUser(name);
|
User user = getUser(name);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return user.getLevel();
|
return user.getLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a user's level
|
* Set a user's level
|
||||||
*
|
*
|
||||||
* @param name Name of the player
|
* @param name Name of the player
|
||||||
* @param level Level to set
|
* @param level Level to set
|
||||||
*/
|
*/
|
||||||
public void safeSetLevel(String name, int level) {
|
public void safeSetLevel(String name, int level) {
|
||||||
User user = getUser(name);
|
User user = getUser(name);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.setLevel(level);
|
user.setLevel(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset a user
|
* Reset a user
|
||||||
*
|
*
|
||||||
* @param name Name of the user
|
* @param name Name of the user
|
||||||
*/
|
*/
|
||||||
public void safeReset(String name) {
|
public void safeReset(String name) {
|
||||||
User user = getUser(name);
|
User user = getUser(name);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.resetLevel();
|
user.resetLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fire an alert
|
* Fire an alert
|
||||||
*
|
*
|
||||||
* @param user The user to alert
|
* @param user The user to alert
|
||||||
* @param level The user's level
|
* @param level The user's level
|
||||||
* @param type The CheckType that triggered the alert
|
* @param type The CheckType that triggered the alert
|
||||||
*/
|
*/
|
||||||
public void alert(User user, Level level, CheckType type) {
|
public void alert(User user, Level level, CheckType type) {
|
||||||
ArrayList<String> messageArray = new ArrayList<String>();
|
ArrayList<String> messageArray = new ArrayList<String>();
|
||||||
for (int i = 0; i < alert.size(); i++) {
|
for (int i = 0; i < alert.size(); i++) {
|
||||||
String message = alert.get(i);
|
String message = alert.get(i);
|
||||||
if (!message.equals("")) {
|
if (!message.equals("")) {
|
||||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||||
message = message.replaceAll("&level", level.getColor() + level.getName() + GRAY);
|
message = message.replaceAll("&level", level.getColor() + level.getName() + GRAY);
|
||||||
messageArray.add(message);
|
messageArray.add(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utilities.alert(messageArray);
|
Utilities.alert(messageArray);
|
||||||
execute(user, level.getActions(), type);
|
execute(user, level.getActions(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute configuration actions for an alert
|
* Execute configuration actions for an alert
|
||||||
*
|
*
|
||||||
* @param user The user
|
* @param user The user
|
||||||
* @param actions The list of actions to execute
|
* @param actions The list of actions to execute
|
||||||
* @param type The CheckType that triggered the alert
|
* @param type The CheckType that triggered the alert
|
||||||
*/
|
*/
|
||||||
public void execute(User user, List<String> actions, CheckType type) {
|
public void execute(User user, List<String> actions, CheckType type) {
|
||||||
execute(user, actions, type, config.getLang().kickReason.getValue(), config.getLang().playerWarning.getValue(), config.getLang().banReason.getValue());
|
execute(user, actions, type, config.getLang().kickReason.getValue(), config.getLang().playerWarning.getValue(), config.getLang().banReason.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute configuration actions for an alert
|
* Execute configuration actions for an alert
|
||||||
*
|
*
|
||||||
* @param user The user
|
* @param user The user
|
||||||
* @param actions The list of actions to execute
|
* @param actions The list of actions to execute
|
||||||
* @param type The CheckType that triggered the alert
|
* @param type The CheckType that triggered the alert
|
||||||
* @param kickReason The config's kick reason
|
* @param kickReason The config's kick reason
|
||||||
* @param warning The config's warning format
|
* @param warning The config's warning format
|
||||||
* @param banReason The config's ban reason
|
* @param banReason The config's ban reason
|
||||||
*/
|
*/
|
||||||
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
|
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
|
||||||
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final String name = user.getName();
|
final String name = user.getName();
|
||||||
for (String event : actions) {
|
for (String event : actions) {
|
||||||
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
|
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
|
||||||
|
|
||||||
if (event.startsWith("COMMAND[")) {
|
if (event.startsWith("COMMAND[")) {
|
||||||
for (String cmd : Utilities.getCommands(event)) {
|
for (String cmd : Utilities.getCommands(event)) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("KICK")) {
|
} else if (event.equalsIgnoreCase("KICK")) {
|
||||||
user.getPlayer().kickPlayer(RED + kickReason);
|
user.getPlayer().kickPlayer(RED + kickReason);
|
||||||
String msg = RED + config.getLang().kickBroadcast.getValue().replaceAll("&player", name);
|
String msg = RED + config.getLang().kickBroadcast.getValue().replaceAll("&player", name);
|
||||||
if (!msg.equals("")) {
|
if (!msg.equals("")) {
|
||||||
Bukkit.broadcastMessage(msg);
|
Bukkit.broadcastMessage(msg);
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("WARN")) {
|
} else if (event.equalsIgnoreCase("WARN")) {
|
||||||
List<String> message = warning;
|
List<String> message = warning;
|
||||||
for (String string : message) {
|
for (String string : message) {
|
||||||
if (!string.equals("")) {
|
if (!string.equals("")) {
|
||||||
user.getPlayer().sendMessage(RED + string);
|
user.getPlayer().sendMessage(RED + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("BAN")) {
|
} else if (event.equalsIgnoreCase("BAN")) {
|
||||||
user.getPlayer().setBanned(true);
|
user.getPlayer().setBanned(true);
|
||||||
user.getPlayer().kickPlayer(RED + banReason);
|
user.getPlayer().kickPlayer(RED + banReason);
|
||||||
String msg = RED + config.getLang().banBroadcast.getValue().replaceAll("&player", name);
|
String msg = RED + config.getLang().banBroadcast.getValue().replaceAll("&player", name);
|
||||||
if (!msg.equals("")) {
|
if (!msg.equals("")) {
|
||||||
Bukkit.broadcastMessage(msg);
|
Bukkit.broadcastMessage(msg);
|
||||||
}
|
}
|
||||||
} else if (event.equalsIgnoreCase("RESET")) {
|
} else if (event.equalsIgnoreCase("RESET")) {
|
||||||
user.resetLevel();
|
user.resetLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+515
-515
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
+239
-239
@@ -1,239 +1,239 @@
|
|||||||
// Not production code yet. Still experimental and needs a lot of work.
|
// Not production code yet. Still experimental and needs a lot of work.
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Calibrator implements Listener {
|
public class Calibrator implements Listener {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private int step = 0;
|
private int step = 0;
|
||||||
private static final int TOTAL = 30;
|
private static final int TOTAL = 30;
|
||||||
private long lastLong;
|
private long lastLong;
|
||||||
private int lastInt;
|
private int lastInt;
|
||||||
private int lastDouble;
|
private int lastDouble;
|
||||||
private long[] longs = new long[10];
|
private long[] longs = new long[10];
|
||||||
private double[] doubles = new double[10];
|
private double[] doubles = new double[10];
|
||||||
private int[] ints = new int[10];
|
private int[] ints = new int[10];
|
||||||
private int times = 0;
|
private int times = 0;
|
||||||
|
|
||||||
// Value-specific calculations
|
// Value-specific calculations
|
||||||
private long projectileTime;
|
private long projectileTime;
|
||||||
private long dropItemTime;
|
private long dropItemTime;
|
||||||
private long punchAvg;
|
private long punchAvg;
|
||||||
private double blockBreakMax;
|
private double blockBreakMax;
|
||||||
private double blockPlaceMax;
|
private double blockPlaceMax;
|
||||||
|
|
||||||
public Calibrator(Player player) {
|
public Calibrator(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
player.sendMessage(ChatColor.GREEN + "----You have entered calibration mode.----");
|
player.sendMessage(ChatColor.GREEN + "----You have entered calibration mode.----");
|
||||||
// Wait for listener to be registered and calibrate method called.
|
// Wait for listener to be registered and calibrate method called.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calibrate() {
|
public void calibrate() {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case 0:
|
case 0:
|
||||||
sendStep();
|
sendStep();
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.BOW));
|
player.getInventory().setItemInHand(new ItemStack(Material.BOW));
|
||||||
player.getInventory().addItem(new ItemStack(Material.ARROW, 64));
|
player.getInventory().addItem(new ItemStack(Material.ARROW, 64));
|
||||||
player.sendMessage("Fire arrows as fast as possible (don't pull all the way back)");
|
player.sendMessage("Fire arrows as fast as possible (don't pull all the way back)");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.DIRT, 64));
|
player.getInventory().setItemInHand(new ItemStack(Material.DIRT, 64));
|
||||||
player.sendMessage("Drop items as fast as possible.");
|
player.sendMessage("Drop items as fast as possible.");
|
||||||
/*
|
/*
|
||||||
* case 0: sendStep(); player.sendMessage("Spam the left mouse button as fast as possible."); break; case 2: player.setGameMode(GameMode.CREATIVE); player.sendMessage("Break blocks from as far away as you can possibly get from them."); break; case 3:
|
* case 0: sendStep(); player.sendMessage("Spam the left mouse button as fast as possible."); break; case 2: player.setGameMode(GameMode.CREATIVE); player.sendMessage("Break blocks from as far away as you can possibly get from them."); break; case 3:
|
||||||
* player.sendMessage("Place blocks from as far away as you can possibly get from them."); break;
|
* player.sendMessage("Place blocks from as far away as you can possibly get from them."); break;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLongCount() {
|
private int getLongCount() {
|
||||||
int fill = 0;
|
int fill = 0;
|
||||||
for (long l : longs) {
|
for (long l : longs) {
|
||||||
if (l != 0) {
|
if (l != 0) {
|
||||||
fill++;
|
fill++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fill;
|
return fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDoubleCount() {
|
private int getDoubleCount() {
|
||||||
int fill = 0;
|
int fill = 0;
|
||||||
for (double d : doubles) {
|
for (double d : doubles) {
|
||||||
if (d != 0) {
|
if (d != 0) {
|
||||||
fill++;
|
fill++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fill;
|
return fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
for (int i = 0; i < longs.length; i++) {
|
for (int i = 0; i < longs.length; i++) {
|
||||||
longs[i] = 0;
|
longs[i] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ints.length; i++) {
|
for (int i = 0; i < ints.length; i++) {
|
||||||
ints[i] = 0;
|
ints[i] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < doubles.length; i++) {
|
for (int i = 0; i < doubles.length; i++) {
|
||||||
doubles[i] = 0;
|
doubles[i] = 0;
|
||||||
}
|
}
|
||||||
lastInt = 0;
|
lastInt = 0;
|
||||||
lastDouble = 0;
|
lastDouble = 0;
|
||||||
lastLong = 0;
|
lastLong = 0;
|
||||||
times = 0;
|
times = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendStep() {
|
private void sendStep() {
|
||||||
step++;
|
step++;
|
||||||
player.sendMessage(ChatColor.GREEN + "Step " + step + "/" + TOTAL);
|
player.sendMessage(ChatColor.GREEN + "Step " + step + "/" + TOTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the average time it takes to do a task
|
// Find the average time it takes to do a task
|
||||||
private long getAvgLong() {
|
private long getAvgLong() {
|
||||||
int count = getLongCount();
|
int count = getLongCount();
|
||||||
if (count < 10) {
|
if (count < 10) {
|
||||||
if (lastLong == 0) {
|
if (lastLong == 0) {
|
||||||
lastLong = System.currentTimeMillis();
|
lastLong = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
longs[count] = System.currentTimeMillis() - lastLong;
|
longs[count] = System.currentTimeMillis() - lastLong;
|
||||||
lastLong = System.currentTimeMillis();
|
lastLong = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
long avg = 0;
|
long avg = 0;
|
||||||
for (long l : longs) {
|
for (long l : longs) {
|
||||||
avg += l;
|
avg += l;
|
||||||
}
|
}
|
||||||
clear();
|
clear();
|
||||||
avg /= 10;
|
avg /= 10;
|
||||||
player.sendMessage(ChatColor.AQUA + "Done. Average calculated at " + ChatColor.WHITE + avg);
|
player.sendMessage(ChatColor.AQUA + "Done. Average calculated at " + ChatColor.WHITE + avg);
|
||||||
sendStep();
|
sendStep();
|
||||||
calibrate();
|
calibrate();
|
||||||
return avg;
|
return avg;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the maximum time it takes to do a task
|
// Find the maximum time it takes to do a task
|
||||||
private double getMaxDouble(double length) {
|
private double getMaxDouble(double length) {
|
||||||
int count = getDoubleCount();
|
int count = getDoubleCount();
|
||||||
if (count < 10) {
|
if (count < 10) {
|
||||||
doubles[count] = length;
|
doubles[count] = length;
|
||||||
} else {
|
} else {
|
||||||
double max = 0;
|
double max = 0;
|
||||||
for (double d : doubles) {
|
for (double d : doubles) {
|
||||||
if (max == 0 || d > max) {
|
if (max == 0 || d > max) {
|
||||||
max = d;
|
max = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clear();
|
clear();
|
||||||
player.sendMessage(ChatColor.AQUA + "Done. Maximum calculated at " + ChatColor.WHITE + max);
|
player.sendMessage(ChatColor.AQUA + "Done. Maximum calculated at " + ChatColor.WHITE + max);
|
||||||
sendStep();
|
sendStep();
|
||||||
calibrate();
|
calibrate();
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the absolute time it takes to do something X times
|
// Get the absolute time it takes to do something X times
|
||||||
private long getAbsoluteLong() {
|
private long getAbsoluteLong() {
|
||||||
int count = getLongCount();
|
int count = getLongCount();
|
||||||
if (count < 10) {
|
if (count < 10) {
|
||||||
if (lastLong == 0) {
|
if (lastLong == 0) {
|
||||||
lastLong = System.currentTimeMillis();
|
lastLong = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
longs[count] = System.currentTimeMillis();
|
longs[count] = System.currentTimeMillis();
|
||||||
lastLong = System.currentTimeMillis();
|
lastLong = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
long val = longs[9] - longs[0];
|
long val = longs[9] - longs[0];
|
||||||
clear();
|
clear();
|
||||||
player.sendMessage(ChatColor.AQUA + "Done. Value calculated at " + ChatColor.WHITE + val);
|
player.sendMessage(ChatColor.AQUA + "Done. Value calculated at " + ChatColor.WHITE + val);
|
||||||
sendStep();
|
sendStep();
|
||||||
calibrate();
|
calibrate();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Begin event listeners
|
// Begin event listeners
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
if (event.getPlayer() == player) {
|
if (event.getPlayer() == player) {
|
||||||
if (step == 2) {
|
if (step == 2) {
|
||||||
long v = getAbsoluteLong();
|
long v = getAbsoluteLong();
|
||||||
if (v != -1) {
|
if (v != -1) {
|
||||||
dropItemTime = v;
|
dropItemTime = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
if (event.getEntity() instanceof Player && ((Player) event.getEntity()) == player) {
|
if (event.getEntity() instanceof Player && ((Player) event.getEntity()) == player) {
|
||||||
if (step == 1) {
|
if (step == 1) {
|
||||||
long v = getAbsoluteLong();
|
long v = getAbsoluteLong();
|
||||||
if (v != -1) {
|
if (v != -1) {
|
||||||
projectileTime = v;
|
projectileTime = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (event.getPlayer() == player) {
|
if (event.getPlayer() == player) {
|
||||||
if (step == -1) {
|
if (step == -1) {
|
||||||
long v = getAvgLong();
|
long v = getAvgLong();
|
||||||
if (v != -1) {
|
if (v != -1) {
|
||||||
punchAvg = v;
|
punchAvg = v;
|
||||||
}
|
}
|
||||||
} else if (step == 1) {
|
} else if (step == 1) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (event.getPlayer() == player) {
|
if (event.getPlayer() == player) {
|
||||||
if (step == -1) {
|
if (step == -1) {
|
||||||
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
||||||
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
||||||
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
||||||
if (v != -1) {
|
if (v != -1) {
|
||||||
blockBreakMax = v;
|
blockBreakMax = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.getPlayer() == player) {
|
if (event.getPlayer() == player) {
|
||||||
if (step == -1) {
|
if (step == -1) {
|
||||||
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
||||||
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
||||||
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
||||||
if (v != -1) {
|
if (v != -1) {
|
||||||
blockPlaceMax = v;
|
blockPlaceMax = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
public class CheckResult {
|
public class CheckResult {
|
||||||
|
|
||||||
+59
-59
@@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class Distance {
|
public class Distance {
|
||||||
private final double l1Y;
|
private final double l1Y;
|
||||||
private final double l2Y;
|
private final double l2Y;
|
||||||
|
|
||||||
private final double XDiff;
|
private final double XDiff;
|
||||||
private final double YDiff;
|
private final double YDiff;
|
||||||
private final double ZDiff;
|
private final double ZDiff;
|
||||||
|
|
||||||
public Distance(Location from, Location to) {
|
public Distance(Location from, Location to) {
|
||||||
l1Y = to.getY();
|
l1Y = to.getY();
|
||||||
l2Y = from.getY();
|
l2Y = from.getY();
|
||||||
|
|
||||||
XDiff = Math.abs(to.getX() - from.getX());
|
XDiff = Math.abs(to.getX() - from.getX());
|
||||||
ZDiff = Math.abs(to.getZ() - from.getZ());
|
ZDiff = Math.abs(to.getZ() - from.getZ());
|
||||||
YDiff = Math.abs(l1Y - l2Y);
|
YDiff = Math.abs(l1Y - l2Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromY() {
|
public double fromY() {
|
||||||
return l2Y;
|
return l2Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double toY() {
|
public double toY() {
|
||||||
return l1Y;
|
return l1Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getXDifference() {
|
public double getXDifference() {
|
||||||
return XDiff;
|
return XDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZDifference() {
|
public double getZDifference() {
|
||||||
return ZDiff;
|
return ZDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYDifference() {
|
public double getYDifference() {
|
||||||
return YDiff;
|
return YDiff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+36
-36
@@ -1,36 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.logging.Formatter;
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
public class FileFormatter extends Formatter {
|
public class FileFormatter extends Formatter {
|
||||||
private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss");
|
private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss");
|
||||||
private static final String LINE_SEP = System.getProperty("line.separator");
|
private static final String LINE_SEP = System.getProperty("line.separator");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record) {
|
||||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
+3
-3
@@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.files.Magic;
|
import net.gravitydevelopment.anticheat.config.files.Magic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
+563
-563
File diff suppressed because it is too large.
Load diff
+5
-5
@@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util.enterprise;
|
package net.gravitydevelopment.anticheat.util.enterprise;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
+4
-4
@@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util.rule;
|
package net.gravitydevelopment.anticheat.util.rule;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
@@ -42,7 +42,7 @@ import java.util.SortedMap;
|
|||||||
* Check_SPIDER > 0 ? Player.KICK : null<br />
|
* Check_SPIDER > 0 ? Player.KICK : null<br />
|
||||||
* <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i>
|
* <i>The above statement would read 'If the spider check has been failed over zero times, kick the player. Otherwise, do nothing.'</i>
|
||||||
* <p/>
|
* <p/>
|
||||||
* To see syntax for variables and functions that you may use, see {@link net.h31ix.anticheat.util.rule.Rule}
|
* To see syntax for variables and functions that you may use, see {@link net.gravitydevelopment.anticheat.util.rule.Rule}
|
||||||
*/
|
*/
|
||||||
public class ConditionalRule extends Rule {
|
public class ConditionalRule extends Rule {
|
||||||
|
|
||||||
+9
-9
@@ -16,12 +16,12 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util.rule;
|
package net.gravitydevelopment.anticheat.util.rule;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.gravitydevelopment.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -39,7 +39,7 @@ import java.util.TreeMap;
|
|||||||
* <br /><br />
|
* <br /><br />
|
||||||
* <p/>
|
* <p/>
|
||||||
* <b>Types of variables:</b><br />
|
* <b>Types of variables:</b><br />
|
||||||
* - Check: Contains all valid checks as listed in {@link net.h31ix.anticheat.manage.CheckType}, and will return the number of times this user has failed the given check<br />
|
* - Check: Contains all valid checks as listed in {@link net.gravitydevelopment.anticheat.manage.CheckType}, and will return the number of times this user has failed the given check<br />
|
||||||
* - Player: Contains LEVEL, the player's current level and CHECK, the check that was just failed
|
* - Player: Contains LEVEL, the player's current level and CHECK, the check that was just failed
|
||||||
* <br /><br />
|
* <br /><br />
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -56,7 +56,7 @@ import java.util.TreeMap;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* The Rule class itself is not an functional rule setup,
|
* The Rule class itself is not an functional rule setup,
|
||||||
* it is inherited and made functional by different implementations of the rule parser.<br />
|
* it is inherited and made functional by different implementations of the rule parser.<br />
|
||||||
* The only current Rule implementation is the {@link net.h31ix.anticheat.util.rule.ConditionalRule}
|
* The only current Rule implementation is the {@link net.gravitydevelopment.anticheat.util.rule.ConditionalRule}
|
||||||
*/
|
*/
|
||||||
public class Rule {
|
public class Rule {
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class Rule {
|
|||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
CONDITIONAL(".*[?]*.*:.*", "net.h31ix.anticheat.util.rule.ConditionalRule");
|
CONDITIONAL(".*[?]*.*:.*", "net.gravitydevelopment.anticheat.util.rule.ConditionalRule");
|
||||||
|
|
||||||
private String regex;
|
private String regex;
|
||||||
private String c;
|
private String c;
|
||||||
@@ -125,7 +125,7 @@ public class Rule {
|
|||||||
/**
|
/**
|
||||||
* Get the type of rule this is
|
* Get the type of rule this is
|
||||||
*
|
*
|
||||||
* @return a {@link net.h31ix.anticheat.util.rule.Rule.Type}
|
* @return a {@link net.gravitydevelopment.anticheat.util.rule.Rule.Type}
|
||||||
*/
|
*/
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
+66
-66
@@ -1,66 +1,66 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.xray;
|
package net.gravitydevelopment.anticheat.xray;
|
||||||
|
|
||||||
import net.h31ix.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.manage.CheckManager;
|
import net.gravitydevelopment.anticheat.manage.CheckManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.gravitydevelopment.anticheat.manage.CheckType;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
|
||||||
public class XRayListener implements Listener {
|
public class XRayListener implements Listener {
|
||||||
private XRayTracker tracker = AntiCheat.getManager().getXRayTracker();
|
private XRayTracker tracker = AntiCheat.getManager().getXRayTracker();
|
||||||
private Configuration config = AntiCheat.getManager().getConfiguration();
|
private Configuration config = AntiCheat.getManager().getConfiguration();
|
||||||
private CheckManager checkManager = AntiCheat.getManager().getCheckManager();
|
private CheckManager checkManager = AntiCheat.getManager().getCheckManager();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (config.getConfig().logXRayStats.getValue()) {
|
if (config.getConfig().logXRayStats.getValue()) {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (p.getGameMode() == GameMode.CREATIVE && !config.getConfig().trackCreativeXRay.getValue()) {
|
if (p.getGameMode() == GameMode.CREATIVE && !config.getConfig().trackCreativeXRay.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String player = p.getName();
|
String player = p.getName();
|
||||||
if (checkManager.willCheck(p, CheckType.XRAY)) {
|
if (checkManager.willCheck(p, CheckType.XRAY)) {
|
||||||
Material m = event.getBlock().getType();
|
Material m = event.getBlock().getType();
|
||||||
if (m == Material.DIAMOND_ORE) {
|
if (m == Material.DIAMOND_ORE) {
|
||||||
tracker.addDiamond(player);
|
tracker.addDiamond(player);
|
||||||
} else if (m == Material.IRON_ORE) {
|
} else if (m == Material.IRON_ORE) {
|
||||||
tracker.addIron(player);
|
tracker.addIron(player);
|
||||||
} else if (m == Material.GOLD_ORE) {
|
} else if (m == Material.GOLD_ORE) {
|
||||||
tracker.addGold(player);
|
tracker.addGold(player);
|
||||||
} else if (m == Material.LAPIS_ORE) {
|
} else if (m == Material.LAPIS_ORE) {
|
||||||
tracker.addLapis(player);
|
tracker.addLapis(player);
|
||||||
} else if (m == Material.REDSTONE_ORE || m == Material.GLOWING_REDSTONE_ORE) {
|
} else if (m == Material.REDSTONE_ORE || m == Material.GLOWING_REDSTONE_ORE) {
|
||||||
tracker.addRedstone(player);
|
tracker.addRedstone(player);
|
||||||
} else if (m == Material.GOLD_ORE) {
|
} else if (m == Material.GOLD_ORE) {
|
||||||
tracker.addGold(player);
|
tracker.addGold(player);
|
||||||
} else {
|
} else {
|
||||||
tracker.addBlock(player);
|
tracker.addBlock(player);
|
||||||
}
|
}
|
||||||
tracker.addTotal(player);
|
tracker.addTotal(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+84
-84
@@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.xray;
|
package net.gravitydevelopment.anticheat.xray;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class XRayStats {
|
public class XRayStats {
|
||||||
private static final int DIVISOR = 100;
|
private static final int DIVISOR = 100;
|
||||||
private double t = 1;
|
private double t = 1;
|
||||||
private double d = 0;
|
private double d = 0;
|
||||||
private double g = 0;
|
private double g = 0;
|
||||||
private double i = 0;
|
private double i = 0;
|
||||||
private double l = 0;
|
private double l = 0;
|
||||||
private double r = 0;
|
private double r = 0;
|
||||||
private double o = 0;
|
private double o = 0;
|
||||||
|
|
||||||
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total) {
|
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total) {
|
||||||
if (total.get(player) != null) {
|
if (total.get(player) != null) {
|
||||||
t = total.get(player);
|
t = total.get(player);
|
||||||
}
|
}
|
||||||
if (diamond.get(player) != null) {
|
if (diamond.get(player) != null) {
|
||||||
d = (diamond.get(player) / t) * DIVISOR;
|
d = (diamond.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (gold.get(player) != null) {
|
if (gold.get(player) != null) {
|
||||||
g = (gold.get(player) / t) * DIVISOR;
|
g = (gold.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (iron.get(player) != null) {
|
if (iron.get(player) != null) {
|
||||||
i = (iron.get(player) / t) * DIVISOR;
|
i = (iron.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (lapis.get(player) != null) {
|
if (lapis.get(player) != null) {
|
||||||
l = (lapis.get(player) / t) * DIVISOR;
|
l = (lapis.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (redstone.get(player) != null) {
|
if (redstone.get(player) != null) {
|
||||||
r = (redstone.get(player) / t) * DIVISOR;
|
r = (redstone.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (other.get(player) != null) {
|
if (other.get(player) != null) {
|
||||||
o = (other.get(player) / t) * DIVISOR;
|
o = (other.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTotal() {
|
public double getTotal() {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDiamond() {
|
public double getDiamond() {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGold() {
|
public double getGold() {
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIron() {
|
public double getIron() {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLapis() {
|
public double getLapis() {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRedstone() {
|
public double getRedstone() {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOther() {
|
public double getOther() {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+152
-152
@@ -1,152 +1,152 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.xray;
|
package net.gravitydevelopment.anticheat.xray;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class XRayTracker {
|
public class XRayTracker {
|
||||||
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> block = new HashMap<String, Integer>();
|
private Map<String, Integer> block = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
||||||
private List<String> alerted = new ArrayList<String>();
|
private List<String> alerted = new ArrayList<String>();
|
||||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
private static final ChatColor RED = ChatColor.RED;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private static final int RATIO_DIVISOR = 3;
|
private static final int RATIO_DIVISOR = 3;
|
||||||
private static final int POWER = 10;
|
private static final int POWER = 10;
|
||||||
private static final int MIN_BLOCK_COUNT = 100;
|
private static final int MIN_BLOCK_COUNT = 100;
|
||||||
|
|
||||||
public XRayTracker() {
|
public XRayTracker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sufficientData(String player) {
|
public boolean sufficientData(String player) {
|
||||||
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculate(CommandSender cs, String player, double x, double b, String type) {
|
public void calculate(CommandSender cs, String player, double x, double b, String type) {
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if (x >= b / RATIO_DIVISOR) {
|
if (x >= b / RATIO_DIVISOR) {
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean calculate(String player, double x, double b) {
|
public boolean calculate(String player, double x, double b) {
|
||||||
return x >= b / RATIO_DIVISOR;
|
return x >= b / RATIO_DIVISOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAbnormal(String player) {
|
public boolean hasAbnormal(String player) {
|
||||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||||
double total = stats.getOther();
|
double total = stats.getOther();
|
||||||
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAlerted(String player) {
|
public boolean hasAlerted(String player) {
|
||||||
return alerted.contains(player);
|
return alerted.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logAlert(String player) {
|
public void logAlert(String player) {
|
||||||
alerted.add(player);
|
alerted.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendStats(CommandSender cs, String player) {
|
public void sendStats(CommandSender cs, String player) {
|
||||||
getStats(cs, player);
|
getStats(cs, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getStats(CommandSender cs, String player) {
|
public void getStats(CommandSender cs, String player) {
|
||||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||||
double total = stats.getOther();
|
double total = stats.getOther();
|
||||||
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
||||||
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
||||||
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
||||||
calculate(cs, player, stats.getGold(), total, "gold");
|
calculate(cs, player, stats.getGold(), total, "gold");
|
||||||
calculate(cs, player, stats.getIron(), total, "iron");
|
calculate(cs, player, stats.getIron(), total, "iron");
|
||||||
calculate(cs, player, stats.getLapis(), total, "lapis");
|
calculate(cs, player, stats.getLapis(), total, "lapis");
|
||||||
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
||||||
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDiamond(String player) {
|
public void addDiamond(String player) {
|
||||||
addOre(player, diamond);
|
addOre(player, diamond);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGold(String player) {
|
public void addGold(String player) {
|
||||||
addOre(player, gold);
|
addOre(player, gold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIron(String player) {
|
public void addIron(String player) {
|
||||||
addOre(player, iron);
|
addOre(player, iron);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLapis(String player) {
|
public void addLapis(String player) {
|
||||||
addOre(player, lapis);
|
addOre(player, lapis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRedstone(String player) {
|
public void addRedstone(String player) {
|
||||||
addOre(player, redstone);
|
addOre(player, redstone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlock(String player) {
|
public void addBlock(String player) {
|
||||||
addOre(player, block);
|
addOre(player, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTotal(String player) {
|
public void addTotal(String player) {
|
||||||
addOre(player, totalblock);
|
addOre(player, totalblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOre(String player, Map<String, Integer> map) {
|
private void addOre(String player, Map<String, Integer> map) {
|
||||||
if (map.get(player) == null || map.get(player) == 0) {
|
if (map.get(player) == null || map.get(player) == 0) {
|
||||||
map.put(player, 1);
|
map.put(player, 1);
|
||||||
} else {
|
} else {
|
||||||
int playerLevel = map.get(player);
|
int playerLevel = map.get(player);
|
||||||
map.put(player, playerLevel + 1);
|
map.put(player, playerLevel + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float round(double num) {
|
private float round(double num) {
|
||||||
double number = num;
|
double number = num;
|
||||||
float p = (float) Math.pow(POWER, 1);
|
float p = (float) Math.pow(POWER, 1);
|
||||||
number *= p;
|
number *= p;
|
||||||
float tmp = Math.round(number);
|
float tmp = Math.round(number);
|
||||||
return tmp / p;
|
return tmp / p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(String player) {
|
public void reset(String player) {
|
||||||
totalblock.put(player, 1);
|
totalblock.put(player, 1);
|
||||||
diamond.put(player, 0);
|
diamond.put(player, 0);
|
||||||
iron.put(player, 0);
|
iron.put(player, 0);
|
||||||
gold.put(player, 0);
|
gold.put(player, 0);
|
||||||
redstone.put(player, 0);
|
redstone.put(player, 0);
|
||||||
lapis.put(player, 0);
|
lapis.put(player, 0);
|
||||||
totalblock.put(player, 0);
|
totalblock.put(player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
author: Gravity
|
author: Gravity
|
||||||
database: false
|
database: false
|
||||||
description: Prevention of hacks and other malicious tinkering on a Minecraft server.
|
description: Prevention of hacks and other malicious tinkering on a Minecraft server.
|
||||||
main: net.h31ix.anticheat.AntiCheat
|
main: net.gravitydevelopment.anticheat.AntiCheat
|
||||||
name: AntiCheat
|
name: AntiCheat
|
||||||
softdepend: [ProtocolLib]
|
softdepend: [ProtocolLib]
|
||||||
startup: postworld
|
startup: postworld
|
||||||
url: http://gravitydevelopment.net
|
url: http://gravitydevelopment.net
|
||||||
version: ${project.version}-b${BUILD_NUMBER}
|
version: ${project.build.version}
|
||||||
commands:
|
commands:
|
||||||
anticheat:
|
anticheat:
|
||||||
description: Control and view info about AntiCheat
|
description: Control and view info about AntiCheat
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat.util;
|
package net.gravitydevelopment.anticheat.util;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
Reference in new issue
Block a user