mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Major refactoring to fix runtime errors, better fastbreak and fly check, and a better API. Thanks a ton @SuperSpyTX
This commit is contained in:
1 parent
d8dc8ed1e0
commit
af91c8a541
22 files changed
+1478
-1204
No files matched your search
+4
-1
@@ -1 +1,4 @@
|
|||||||
/target/
|
/target/
|
||||||
|
/bin/
|
||||||
|
/.settings/
|
||||||
|
/.*
|
||||||
Whitespace-only changes.
@@ -12,6 +12,7 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
|
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -24,7 +25,18 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>AntiCheat</finalName>
|
<finalName>AntiCheat</finalName>
|
||||||
</build>
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>${basedir}/src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>plugin.yml</include>
|
||||||
|
<include>config.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
@@ -41,11 +53,17 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>12.0</version>
|
<version>12.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -45,9 +45,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Anticheat extends JavaPlugin
|
public class Anticheat extends JavaPlugin
|
||||||
{
|
{
|
||||||
private static Anticheat plugin;
|
private static AnticheatManager manager;
|
||||||
private final List<Listener> eventList = new ArrayList<Listener>();
|
private final List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static boolean update = false;
|
private static boolean update = false;
|
||||||
private static final int BYTE_SIZE = 1024;
|
private static final int BYTE_SIZE = 1024;
|
||||||
@@ -56,13 +56,13 @@ public class Anticheat extends JavaPlugin
|
|||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static String updateFolder;
|
private static String updateFolder;
|
||||||
private static Metrics metrics;
|
private static Metrics metrics;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
Map<String,Integer> map = AnticheatManager.PLAYER_MANAGER.getLevels();
|
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
||||||
Iterator<String> set = map.keySet().iterator();
|
Iterator<String> set = map.keySet().iterator();
|
||||||
while(set.hasNext())
|
while (set.hasNext())
|
||||||
{
|
{
|
||||||
String player = set.next();
|
String player = set.next();
|
||||||
config.saveLevel(player, map.get(player));
|
config.saveLevel(player, map.get(player));
|
||||||
@@ -74,8 +74,8 @@ public class Anticheat extends JavaPlugin
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
plugin = this;
|
manager = new AnticheatManager(this);
|
||||||
config = AnticheatManager.CONFIGURATION;
|
config = manager.getConfiguration();
|
||||||
checkConfig();
|
checkConfig();
|
||||||
verbose = config.verboseStartup();
|
verbose = config.verboseStartup();
|
||||||
updateFolder = config.updateFolder();
|
updateFolder = config.updateFolder();
|
||||||
@@ -84,55 +84,62 @@ public class Anticheat extends JavaPlugin
|
|||||||
eventList.add(new BlockListener());
|
eventList.add(new BlockListener());
|
||||||
eventList.add(new EntityListener());
|
eventList.add(new EntityListener());
|
||||||
eventList.add(new VehicleListener());
|
eventList.add(new VehicleListener());
|
||||||
final XRayTracker xtracker = AnticheatManager.XRAY_TRACKER;
|
final XRayTracker xtracker = manager.getXRayTracker();
|
||||||
if(config.logXRay())
|
if (config.logXRay())
|
||||||
{
|
{
|
||||||
eventList.add(new XRayListener());
|
eventList.add(new XRayListener());
|
||||||
if(config.alertXRay())
|
if (config.alertXRay())
|
||||||
{
|
{
|
||||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
for(Player player : getServer().getOnlinePlayers())
|
@Override
|
||||||
{
|
public void run()
|
||||||
String name = player.getName();
|
|
||||||
if(!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
|
||||||
{
|
{
|
||||||
String [] alert = new String[2];
|
for (Player player : getServer().getOnlinePlayers())
|
||||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+name+ChatColor.YELLOW+" might be using xray.";
|
{
|
||||||
alert[1] = ChatColor.YELLOW+"[ALERT] Please check their xray stats using "+ChatColor.WHITE+"/anticheat xray "+name+ChatColor.YELLOW+".";
|
String name = player.getName();
|
||||||
Utilities.alert(alert);
|
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||||
xtracker.logAlert(name);
|
{
|
||||||
|
String[] alert = new String[2];
|
||||||
|
alert[0] = ChatColor.YELLOW
|
||||||
|
+ "[ALERT] " + ChatColor.WHITE
|
||||||
|
+ name + ChatColor.YELLOW
|
||||||
|
+ " might be using xray.";
|
||||||
|
alert[1] = ChatColor.YELLOW
|
||||||
|
+ "[ALERT] Please check their xray stats using "
|
||||||
|
+ ChatColor.WHITE
|
||||||
|
+ "/anticheat xray " + name
|
||||||
|
+ ChatColor.YELLOW + ".";
|
||||||
|
Utilities.alert(alert);
|
||||||
|
xtracker.logAlert(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 1200L, 1200L);
|
||||||
}
|
|
||||||
}, 1200L, 1200L);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Listener listener : eventList)
|
for (Listener listener : eventList)
|
||||||
{
|
{
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Registered events for ".concat(listener.toString()));
|
logger.log(Level.INFO, "[AC] Registered events for ".concat(listener.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Registered commands");
|
logger.log(Level.INFO, "[AC] Registered commands");
|
||||||
logger.log(Level.INFO,"[AC] Finished loading.");
|
logger.log(Level.INFO, "[AC] Finished loading.");
|
||||||
}
|
}
|
||||||
if(update && config.autoUpdate())
|
if (update && config.autoUpdate())
|
||||||
{
|
{
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Downloading the new update...");
|
logger.log(Level.INFO, "[AC] Downloading the new update...");
|
||||||
}
|
}
|
||||||
File file = new File("plugins/"+updateFolder);
|
File file = new File("plugins/" + updateFolder);
|
||||||
if(!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -141,28 +148,24 @@ public class Anticheat extends JavaPlugin
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
saveFile(file.getCanonicalPath()+"/AntiCheat.jar", "http://dl.dropbox.com/u/38228324/AntiCheat.jar");
|
saveFile(file.getCanonicalPath() + "/AntiCheat.jar","http://dl.dropbox.com/u/38228324/AntiCheat.jar");
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
logger.log(Level.INFO,"[AC] Enabling metrics...");
|
|
||||||
}
|
|
||||||
metrics = new Metrics(this);
|
metrics = new Metrics(this);
|
||||||
final EventListener listener = new EventListener();
|
final EventListener listener = new EventListener();
|
||||||
Graph graph = metrics.createGraph("Hacks blocked");
|
Graph graph = metrics.createGraph("Hacks blocked");
|
||||||
for(final CheckType type : CheckType.values())
|
for (final CheckType type : CheckType.values())
|
||||||
{
|
{
|
||||||
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]);
|
||||||
graph.addPlotter(new Metrics.Plotter(new String(chars))
|
graph.addPlotter(new Metrics.Plotter(new String(chars))
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -170,170 +173,165 @@ public class Anticheat extends JavaPlugin
|
|||||||
{
|
{
|
||||||
return listener.getCheats(type);
|
return listener.getCheats(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
listener.resetCheck(type);
|
listener.resetCheck(type);
|
||||||
}
|
}
|
||||||
metrics.start();
|
metrics.start();
|
||||||
if(verbose)
|
}
|
||||||
{
|
|
||||||
logger.log(Level.INFO,"[AC] Metrics started.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
for(Player player : getServer().getOnlinePlayers())
|
for (Player player : getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
AnticheatManager.PLAYER_MANAGER.setLevel(player, config.getLevel(name));
|
manager.getPlayerManager().setLevel(player,config.getLevel(name));
|
||||||
}
|
}
|
||||||
if(verbose)
|
}
|
||||||
{
|
|
||||||
logger.log(Level.INFO,"[AC] Player's levels collected from storage and applied.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveFile(String file, String url)
|
|
||||||
{
|
|
||||||
BufferedInputStream in = null;
|
|
||||||
FileOutputStream fout = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
in = new BufferedInputStream(new URL(url).openStream());
|
|
||||||
fout = new FileOutputStream(file);
|
|
||||||
|
|
||||||
byte[] data = new byte[BYTE_SIZE];
|
private void saveFile(String file, String url)
|
||||||
int count;
|
|
||||||
while ((count = in.read(data, 0, BYTE_SIZE)) != -1)
|
|
||||||
{
|
|
||||||
fout.write(data, 0, count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
{
|
||||||
|
BufferedInputStream in = null;
|
||||||
}
|
FileOutputStream fout = null;
|
||||||
finally
|
try
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (in != null)
|
in = new BufferedInputStream(new URL(url).openStream());
|
||||||
{
|
fout = new FileOutputStream(file);
|
||||||
in.close();
|
|
||||||
}
|
byte[] data = new byte[BYTE_SIZE];
|
||||||
if (fout != null)
|
int count;
|
||||||
{
|
while ((count = in.read(data, 0, BYTE_SIZE)) != -1)
|
||||||
fout.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
logger.log(Level.INFO,"[AC] AntiCheat update has been downloaded and will be installed on next launch.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkConfig()
|
|
||||||
{
|
|
||||||
if(!new File(plugin.getDataFolder()+"/config.yml").exists())
|
|
||||||
{
|
|
||||||
plugin.saveDefaultConfig();
|
|
||||||
if(verbose)
|
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Config file created");
|
fout.write(data, 0, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
|
|
||||||
private void checkForUpdate()
|
|
||||||
{
|
|
||||||
if(verbose)
|
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Checking for updates...");
|
}
|
||||||
}
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (in != null)
|
||||||
|
{
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
if (fout != null)
|
||||||
|
{
|
||||||
|
fout.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO,"[AC] AntiCheat update has been downloaded and will be installed on next launch.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkConfig()
|
||||||
|
{
|
||||||
|
if (!new File(getDataFolder() + "/config.yml").exists())
|
||||||
|
{
|
||||||
|
saveDefaultConfig();
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO, "[AC] Config file created");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForUpdate()
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO, "[AC] Checking for updates...");
|
||||||
|
}
|
||||||
URL url = null;
|
URL url = null;
|
||||||
URLConnection urlConn = null;
|
URLConnection urlConn = null;
|
||||||
InputStreamReader inStream = null;
|
InputStreamReader inStream = null;
|
||||||
BufferedReader buff = null;
|
BufferedReader buff = null;
|
||||||
String v = "";
|
String v = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
url = new URL("http://dl.dropbox.com/u/38228324/anticheatVersion.txt");
|
url = new URL("http://dl.dropbox.com/u/38228324/anticheatVersion.txt");
|
||||||
urlConn = url.openConnection();
|
urlConn = url.openConnection();
|
||||||
inStream = new InputStreamReader(urlConn.getInputStream());
|
inStream = new InputStreamReader(urlConn.getInputStream());
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
buff= new BufferedReader(inStream);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
v =buff.readLine();
|
|
||||||
urlConn = null;
|
|
||||||
inStream = null;
|
|
||||||
buff.close();
|
|
||||||
buff = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if (!this.getDescription().getVersion().equalsIgnoreCase(v))
|
buff = new BufferedReader(inStream);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
v = buff.readLine();
|
||||||
|
urlConn = null;
|
||||||
|
inStream = null;
|
||||||
|
buff.close();
|
||||||
|
buff = null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if (!this.getDescription().getVersion().equalsIgnoreCase(v))
|
||||||
{
|
{
|
||||||
String version = this.getDescription().getVersion();
|
String version = this.getDescription().getVersion();
|
||||||
if(version.endsWith("-PRE") || version.endsWith("-DEV"))
|
if (version.endsWith("-PRE") || version.endsWith("-DEV"))
|
||||||
{
|
{
|
||||||
if(version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Your dev build has been promoted to release. Downloading the update.");
|
logger.log(Level.INFO,"[AC] Your dev build has been promoted to release. Downloading the update.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update = false;
|
update = false;
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] Dev build detected, so skipping update checking until this version is released.");
|
logger.log(Level.INFO,"[AC] Dev build detected, so skipping update checking until this version is released.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] An update was found.");
|
logger.log(Level.INFO, "[AC] An update was found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"[AC] No update found.");
|
logger.log(Level.INFO, "[AC] No update found.");
|
||||||
}
|
}
|
||||||
update = false;
|
update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Anticheat getPlugin()
|
public static Anticheat getPlugin()
|
||||||
{
|
{
|
||||||
return plugin;
|
return manager.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUpdated()
|
public static AnticheatManager getManager()
|
||||||
|
{
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isUpdated()
|
||||||
{
|
{
|
||||||
return !update;
|
return !update;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion()
|
public static String getVersion()
|
||||||
{
|
{
|
||||||
return plugin.getDescription().getVersion();
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,335 +1,335 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||||
import net.h31ix.anticheat.manage.PlayerManager;
|
import net.h31ix.anticheat.manage.PlayerManager;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.h31ix.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;
|
||||||
|
|
||||||
public class CommandHandler implements CommandExecutor {
|
public class CommandHandler implements CommandExecutor
|
||||||
|
{
|
||||||
private Configuration config = AnticheatManager.CONFIGURATION;
|
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private PlayerManager playerManager = AnticheatManager.PLAYER_MANAGER;
|
private PlayerManager playerManager = Anticheat.getManager().getPlayerManager();
|
||||||
private XRayTracker xtracker = AnticheatManager.XRAY_TRACKER;
|
private XRayTracker xtracker = 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 List<Player> high = new ArrayList<Player>();
|
private List<Player> high = new ArrayList<Player>();
|
||||||
private List<Player> med = new ArrayList<Player>();
|
private List<Player> med = new ArrayList<Player>();
|
||||||
private List<Player> low = new ArrayList<Player>();
|
private List<Player> low = new ArrayList<Player>();
|
||||||
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;
|
||||||
|
|
||||||
public void handleLog(CommandSender cs, String [] args)
|
public void handleLog(CommandSender cs, String [] args)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.log") || hasPermission(cs,"admin"))
|
if(hasPermission(cs,"system.log") || hasPermission(cs,"admin"))
|
||||||
{
|
{
|
||||||
if(args[1].equalsIgnoreCase("enable"))
|
if(args[1].equalsIgnoreCase("enable"))
|
||||||
{
|
{
|
||||||
if(!config.logConsole())
|
if(!config.logConsole())
|
||||||
{
|
{
|
||||||
config.setLog(true);
|
config.setLog(true);
|
||||||
cs.sendMessage(GREEN+"Console logging enabled.");
|
cs.sendMessage(GREEN+"Console logging enabled.");
|
||||||
}
|
}
|
||||||
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.logConsole())
|
if(config.logConsole())
|
||||||
{
|
{
|
||||||
config.setLog(false);
|
config.setLog(false);
|
||||||
cs.sendMessage(GREEN+"Console logging disabled.");
|
cs.sendMessage(GREEN+"Console logging disabled.");
|
||||||
}
|
}
|
||||||
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 handleXRay(CommandSender cs, String [] args)
|
public void handleXRay(CommandSender cs, String [] args)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.xray") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
if(hasPermission(cs,"system.xray") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||||
{
|
{
|
||||||
if(config.logXRay())
|
if(config.logXRay())
|
||||||
{
|
{
|
||||||
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(xtracker.sufficientData(player.getName()))
|
if(xtracker.sufficientData(player.getName()))
|
||||||
{
|
{
|
||||||
xtracker.sendStats(cs, player.getName());
|
xtracker.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(xtracker.sufficientData(args[1]))
|
else if(xtracker.sufficientData(args[1]))
|
||||||
{
|
{
|
||||||
xtracker.sendStats(cs, args[1]);
|
xtracker.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,"system.reset") || hasPermission(cs,"admin"))
|
if(hasPermission(cs,"system.reset") || hasPermission(cs,"admin"))
|
||||||
{
|
{
|
||||||
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);
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if(low.contains(player))
|
if(low.contains(player))
|
||||||
{
|
{
|
||||||
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
||||||
}
|
}
|
||||||
else if (med.contains(player) || high.contains(player))
|
else if (med.contains(player) || high.contains(player))
|
||||||
{
|
{
|
||||||
playerManager.reset(player);
|
playerManager.reset(player);
|
||||||
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
||||||
}
|
}
|
||||||
xtracker.reset(player.getName());
|
xtracker.reset(player.getName());
|
||||||
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
||||||
}
|
}
|
||||||
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 handleHelp(CommandSender cs)
|
public void handleHelp(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||||
{
|
{
|
||||||
String base = "/AntiCheat ";
|
String base = "/AntiCheat ";
|
||||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||||
cs.sendMessage(base+GREEN+"log [Enable/Disable]"+WHITE+" - toggle logging");
|
cs.sendMessage(base+GREEN+"log [Enable/Disable]"+WHITE+" - toggle logging");
|
||||||
cs.sendMessage(base+GREEN+"report"+WHITE+" - get a detailed cheat report");
|
cs.sendMessage(base+GREEN+"report"+WHITE+" - get a detailed cheat report");
|
||||||
cs.sendMessage(base+GREEN+"reload"+WHITE+" - reload AntiCheat configuration");
|
cs.sendMessage(base+GREEN+"reload"+WHITE+" - reload AntiCheat configuration");
|
||||||
cs.sendMessage(base+GREEN+"reset [user]"+WHITE+" - reset user's hack level");
|
cs.sendMessage(base+GREEN+"reset [user]"+WHITE+" - reset user's hack level");
|
||||||
cs.sendMessage(base+GREEN+"xray [user]"+WHITE+" - check user's xray levels");
|
cs.sendMessage(base+GREEN+"xray [user]"+WHITE+" - check user's xray levels");
|
||||||
cs.sendMessage(base+GREEN+"help"+WHITE+" - access this page");
|
cs.sendMessage(base+GREEN+"help"+WHITE+" - access this page");
|
||||||
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleUpdate(CommandSender cs)
|
public void handleUpdate(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.update") || hasPermission(cs,"admin"))
|
if(hasPermission(cs,"system.update") || hasPermission(cs,"admin"))
|
||||||
{
|
{
|
||||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
if(!Anticheat.isUpdated())
|
if(!Anticheat.isUpdated())
|
||||||
{
|
{
|
||||||
cs.sendMessage("There "+GREEN+"IS"+WHITE+" a newer version avaliable.");
|
cs.sendMessage("There "+GREEN+"IS"+WHITE+" a newer version avaliable.");
|
||||||
if(config.autoUpdate())
|
if(config.autoUpdate())
|
||||||
{
|
{
|
||||||
cs.sendMessage("It will be installed automatically for you on next launch.");
|
cs.sendMessage("It will be installed automatically for you on next launch.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage("Due to your config settings, we "+RED+"can not"+WHITE+" auto update.");
|
cs.sendMessage("Due to your config settings, we "+RED+"can not"+WHITE+" auto update.");
|
||||||
cs.sendMessage("Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
cs.sendMessage("Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage("AntiCheat is "+GREEN+"UP TO DATE!");
|
cs.sendMessage("AntiCheat is "+GREEN+"UP TO DATE!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReport(CommandSender cs)
|
public void handleReport(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.report") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
if(hasPermission(cs,"system.report") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||||
{
|
{
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if(!low.isEmpty())
|
if(!low.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
||||||
for(Player player : low)
|
for(Player player : low)
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+player.getName());
|
cs.sendMessage(GREEN+player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!med.isEmpty())
|
if(!med.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
||||||
for(Player player : med)
|
for(Player player : med)
|
||||||
{
|
{
|
||||||
cs.sendMessage(YELLOW+player.getName());
|
cs.sendMessage(YELLOW+player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!high.isEmpty())
|
if(!high.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
||||||
for(Player player : high)
|
for(Player player : high)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+player.getName());
|
cs.sendMessage(RED+player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReload(CommandSender cs)
|
public void handleReload(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.reload") || hasPermission(cs,"admin"))
|
if(hasPermission(cs,"system.reload") || hasPermission(cs,"admin"))
|
||||||
{
|
{
|
||||||
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 == 2)
|
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("reset"))
|
else if(args[0].equalsIgnoreCase("reset"))
|
||||||
{
|
{
|
||||||
handleReset(cs,args);
|
handleReset(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("report"))
|
else if(args[0].equalsIgnoreCase("report"))
|
||||||
{
|
{
|
||||||
handleReport(cs);
|
handleReport(cs);
|
||||||
}
|
}
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command.");
|
cs.sendMessage(RED+"Unrecognized command.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(CommandSender cs, String permission)
|
public boolean hasPermission(CommandSender cs, String permission)
|
||||||
{
|
{
|
||||||
if(cs instanceof Player)
|
if(cs instanceof Player)
|
||||||
{
|
{
|
||||||
if(((Player)cs).hasPermission("anticheat."+permission))
|
if(((Player)cs).hasPermission("anticheat."+permission))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage("Insufficient permissions.");
|
cs.sendMessage("Insufficient permissions.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 = playerManager.getLevel(player);
|
int level = playerManager.getLevel(player);
|
||||||
if(level <= MED_THRESHOLD)
|
if(level <= MED_THRESHOLD)
|
||||||
{
|
{
|
||||||
low.add(player);
|
low.add(player);
|
||||||
}
|
}
|
||||||
else if(level <= HIGH_THRESHOLD)
|
else if(level <= HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
med.add(player);
|
med.add(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
high.add(player);
|
high.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,15 +24,20 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration
|
||||||
private File configFile = new File(Anticheat.getPlugin().getDataFolder()+"/config.yml");
|
{
|
||||||
private File levelFile = new File(Anticheat.getPlugin().getDataFolder()+"/data/level.yml");
|
private AnticheatManager micromanage = null; //like a boss!
|
||||||
private File bukkitFile = new File("bukkit.yml");
|
private File configFile = null;
|
||||||
|
private File levelFile = null;
|
||||||
|
private File bukkitFile = null;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
private FileConfiguration level;
|
private FileConfiguration level;
|
||||||
private FileConfiguration bukkit;
|
private FileConfiguration bukkit;
|
||||||
@@ -44,8 +49,12 @@ public class Configuration {
|
|||||||
private String updateFolder;
|
private String updateFolder;
|
||||||
private List<String> worlds = new ArrayList<String>();
|
private List<String> worlds = new ArrayList<String>();
|
||||||
|
|
||||||
public Configuration()
|
public Configuration(AnticheatManager instance)
|
||||||
{
|
{
|
||||||
|
micromanage = instance;
|
||||||
|
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
||||||
|
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
||||||
|
bukkitFile = new File("bukkit.yml");
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +102,7 @@ public class Configuration {
|
|||||||
|
|
||||||
public final void load()
|
public final void load()
|
||||||
{
|
{
|
||||||
Anticheat.checkConfig();
|
micromanage.getPlugin().checkConfig();
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||||
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package net.h31ix.anticheat.api;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
|
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||||
|
import net.h31ix.anticheat.manage.CheckManager;
|
||||||
|
import net.h31ix.anticheat.manage.CheckType;
|
||||||
|
import net.h31ix.anticheat.manage.PlayerManager;
|
||||||
|
import net.h31ix.anticheat.xray.XRayTracker;
|
||||||
|
|
||||||
|
public class AnticheatAPI
|
||||||
|
{
|
||||||
|
private static CheckManager chk = Anticheat.getManager().getCheckManager();
|
||||||
|
private static PlayerManager pmr = Anticheat.getManager().getPlayerManager();
|
||||||
|
private static XRayTracker xtracker = Anticheat.getManager().getXRayTracker();
|
||||||
|
|
||||||
|
//CheckManager API.
|
||||||
|
|
||||||
|
public static void activateCheck(CheckType type)
|
||||||
|
{
|
||||||
|
chk.activateCheck(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deactivateCheck(CheckType type)
|
||||||
|
{
|
||||||
|
chk.deactivateCheck(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isActive(CheckType type)
|
||||||
|
{
|
||||||
|
return chk.isActive(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void exemptPlayer(Player player, CheckType type)
|
||||||
|
{
|
||||||
|
chk.exemptPlayer(player, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unexemptPlayer(Player player, CheckType type)
|
||||||
|
{
|
||||||
|
chk.unexemptPlayer(player, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isExempt(Player player, CheckType type)
|
||||||
|
{
|
||||||
|
return chk.isExempt(player, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//PlayerManager API
|
||||||
|
|
||||||
|
public static int getLevel(Player player)
|
||||||
|
{
|
||||||
|
if(!pmr.hasLevel(player))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return pmr.getLevel(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLevel(Player player, int x)
|
||||||
|
{
|
||||||
|
pmr.setLevel(player, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
//XrayTracker API
|
||||||
|
|
||||||
|
public static boolean isXrayer(Player player)
|
||||||
|
{
|
||||||
|
String name = player.getName();
|
||||||
|
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Advanced Users Only API.
|
||||||
|
|
||||||
|
public static AnticheatManager getManager()
|
||||||
|
{
|
||||||
|
return Anticheat.getManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,122 +1,121 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import net.h31ix.anticheat.manage.Backend;
|
import net.h31ix.anticheat.manage.Backend;
|
||||||
import net.h31ix.anticheat.manage.CheckManager;
|
import net.h31ix.anticheat.manage.CheckManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.h31ix.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.Distance;
|
import net.h31ix.anticheat.manage.Distance;
|
||||||
import org.bukkit.GameMode;
|
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.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
|
{
|
||||||
{
|
private final Backend backend = getBackend();
|
||||||
private final Backend backend = getBackend();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final Anticheat plugin = getPlugin();
|
||||||
private final Anticheat plugin = getPlugin();
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onBlockDamage(BlockDamageEvent event)
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
{
|
||||||
{
|
if(event.getInstaBreak())
|
||||||
if(event.getInstaBreak())
|
{
|
||||||
{
|
backend.logInstantBreak(event.getPlayer());
|
||||||
backend.logInstantBreak(event.getPlayer());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
{
|
||||||
{
|
final Player player = event.getPlayer();
|
||||||
final Player player = event.getPlayer();
|
Block block = event.getBlock();
|
||||||
Block block = event.getBlock();
|
if(player != null)
|
||||||
if(player != null && player.getGameMode() != GameMode.CREATIVE)
|
{
|
||||||
{
|
if(checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_PLACE))
|
{
|
||||||
{
|
if(backend.checkFastPlace(player))
|
||||||
if(backend.justPlaced(player))
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
||||||
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
decrease(player);
|
||||||
decrease(player);
|
backend.logBlockPlace(player);
|
||||||
backend.logBlockPlace(player);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
{
|
||||||
{
|
final Player player = event.getPlayer();
|
||||||
final Player player = event.getPlayer();
|
Block block = event.getBlock();
|
||||||
Block block = event.getBlock();
|
boolean noHack = true;
|
||||||
boolean noHack = true;
|
if(player != null)
|
||||||
if(player != null)
|
{
|
||||||
{
|
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
{
|
||||||
{
|
if(backend.checkSwing(player))
|
||||||
if(backend.checkSwing(player))
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
||||||
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
noHack = false;
|
||||||
noHack = false;
|
}
|
||||||
}
|
}
|
||||||
}
|
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||||
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
{
|
||||||
{
|
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
||||||
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
if(backend.checkLongReachBlock(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||||
if(backend.checkLongReachBlock(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
log("tried to break a block of "+block.getType().name()+" that was too far away.",player,CheckType.LONG_REACH);
|
||||||
log("tried to break a block of "+block.getType().name()+" that was too far away.",player,CheckType.LONG_REACH);
|
noHack = false;
|
||||||
noHack = false;
|
}
|
||||||
}
|
}
|
||||||
}
|
if(checkManager.willCheck(player, CheckType.FAST_BREAK))
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_BREAK))
|
{
|
||||||
{
|
if(backend.checkFastBreak(player,block))
|
||||||
if(backend.checkFastBreak(player,block))
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
log("tried to break a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_BREAK);
|
||||||
log("tried to break a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_BREAK);
|
noHack = false;
|
||||||
noHack = false;
|
}
|
||||||
}
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
{
|
||||||
{
|
@Override
|
||||||
@Override
|
public void run()
|
||||||
public void run()
|
{
|
||||||
{
|
backend.checkSwing(player);
|
||||||
backend.checkSwing(player);
|
}
|
||||||
}
|
}, 2L);
|
||||||
}, 2L);
|
}
|
||||||
}
|
}
|
||||||
}
|
if(noHack)
|
||||||
if(noHack)
|
{
|
||||||
{
|
decrease(player);
|
||||||
decrease(player);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,162 +1,162 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.Backend;
|
import net.h31ix.anticheat.manage.Backend;
|
||||||
import net.h31ix.anticheat.manage.CheckManager;
|
import net.h31ix.anticheat.manage.CheckManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.h31ix.anticheat.manage.CheckType;
|
||||||
import net.h31ix.anticheat.manage.Distance;
|
import net.h31ix.anticheat.manage.Distance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
|
||||||
|
|
||||||
public class EntityListener extends EventListener
|
public class EntityListener extends EventListener
|
||||||
{
|
{
|
||||||
private final Backend backend = getBackend();
|
private final Backend backend = getBackend();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
|
|
||||||
@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(checkManager.willCheck(player, CheckType.FAST_BOW))
|
if(checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||||
{
|
{
|
||||||
if(backend.justWoundUp(player))
|
if(backend.justWoundUp(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
if(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||||
{
|
{
|
||||||
if(backend.justHealed(player))
|
if(backend.justHealed(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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(checkManager.willCheck(player, CheckType.FAST_EAT))
|
if(checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||||
{
|
{
|
||||||
if(backend.justStartedEating(player))
|
if(backend.justStartedEating(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
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();
|
||||||
if (e.getDamager() instanceof Player)
|
if (e.getDamager() instanceof Player)
|
||||||
{
|
{
|
||||||
Player p = (Player)e.getDamager();
|
Player p = (Player)e.getDamager();
|
||||||
backend.logDamage(p);
|
backend.logDamage(p);
|
||||||
backend.logDamage(player);
|
backend.logDamage(player);
|
||||||
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||||
{
|
{
|
||||||
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
||||||
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to damage a player too far away from them.",p,CheckType.LONG_REACH);
|
log("tried to damage a player too far away from them.",p,CheckType.LONG_REACH);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
backend.logDamage(player);
|
backend.logDamage(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(e.getDamager() instanceof Player)
|
if(e.getDamager() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||||
{
|
{
|
||||||
if(backend.justSprinted(player))
|
if(backend.justSprinted(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||||
{
|
{
|
||||||
if(!backend.justAnimated(player))
|
if(!backend.justAnimated(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noHack)
|
if(noHack)
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,16 +30,16 @@ public class EventListener implements Listener
|
|||||||
{
|
{
|
||||||
private static final Map<CheckType,Integer> usageList = new EnumMap<CheckType,Integer>(CheckType.class);
|
private static final Map<CheckType,Integer> usageList = new EnumMap<CheckType,Integer>(CheckType.class);
|
||||||
private static final Map<String,Integer> decreaseList = new HashMap<String,Integer>();
|
private static final Map<String,Integer> decreaseList = new HashMap<String,Integer>();
|
||||||
private static final CheckManager CHECK_MANAGER = AnticheatManager.CHECK_MANAGER;
|
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
||||||
private static final Backend BACKEND = AnticheatManager.BACKEND;
|
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
||||||
private static final Anticheat PLUGIN = Anticheat.getPlugin();
|
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
||||||
private static final PlayerManager PLAYER_MANAGER = AnticheatManager.PLAYER_MANAGER;
|
private static final PlayerManager PLAYER_MANAGER = Anticheat.getManager().getPlayerManager();
|
||||||
|
|
||||||
public void log(String message,Player player, CheckType type)
|
public void log(String message,Player player, CheckType type)
|
||||||
{
|
{
|
||||||
if(AnticheatManager.CONFIGURATION.logConsole())
|
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
AnticheatManager.log(player.getName()+" "+message);
|
Anticheat.getManager().log(player.getName()+" "+message);
|
||||||
}
|
}
|
||||||
PLAYER_MANAGER.increaseLevel(player);
|
PLAYER_MANAGER.increaseLevel(player);
|
||||||
removeDecrease(player);
|
removeDecrease(player);
|
||||||
@@ -102,11 +102,19 @@ public class EventListener implements Listener
|
|||||||
return CHECK_MANAGER;
|
return CHECK_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AnticheatManager getManager() {
|
||||||
|
return Anticheat.getManager();
|
||||||
|
}
|
||||||
|
|
||||||
public static Backend getBackend()
|
public static Backend getBackend()
|
||||||
{
|
{
|
||||||
return BACKEND;
|
return BACKEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerManager getPlayerManager() {
|
||||||
|
return PLAYER_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
public static Anticheat getPlugin()
|
public static Anticheat getPlugin()
|
||||||
{
|
{
|
||||||
return PLUGIN;
|
return PLUGIN;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import net.h31ix.anticheat.manage.*;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.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;
|
||||||
@@ -154,20 +155,20 @@ public class PlayerListener extends EventListener
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||||
{
|
{
|
||||||
player.sendMessage("§f §f §1 §0 §2 §4");
|
player.sendMessage("§f §f §1 §0 §2 §4");
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
||||||
{
|
{
|
||||||
player.sendMessage("§f §f §2 §0 §4 §8");
|
player.sendMessage("§f §f §2 §0 §4 §8");
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
||||||
{
|
{
|
||||||
player.sendMessage("§f §f §4 §0 §9 §6");
|
player.sendMessage("§f §f §4 §0 §9 §6");
|
||||||
}
|
}
|
||||||
backend.logJoin(event.getPlayer());
|
backend.logJoin(event.getPlayer());
|
||||||
if(!AnticheatManager.PLAYER_MANAGER.hasLevel(player))
|
if(!getPlayerManager().hasLevel(player))
|
||||||
{
|
{
|
||||||
AnticheatManager.PLAYER_MANAGER.setLevel(player, AnticheatManager.CONFIGURATION.getLevel(player.getName()));
|
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +185,17 @@ public class PlayerListener extends EventListener
|
|||||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, from.getY(), to.getY()))
|
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, from.getY(), to.getY()))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
|
//Lets really give this flyer a real pushdown.
|
||||||
|
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ());
|
||||||
|
Block whatever = newLocation.getBlock();
|
||||||
|
if(whatever.getTypeId() != 0)
|
||||||
|
{
|
||||||
|
event.setTo(newLocation);
|
||||||
|
}
|
||||||
|
/* else
|
||||||
|
{
|
||||||
|
downlow--;
|
||||||
|
}*/
|
||||||
log("tried to fly.",player,CheckType.FLY);
|
log("tried to fly.",player,CheckType.FLY);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||||
@@ -220,7 +232,7 @@ public class PlayerListener extends EventListener
|
|||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.SNEAK) && checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkSneak(player,x,z))
|
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
player.setSneaking(false);
|
player.setSneaking(false);
|
||||||
@@ -232,4 +244,4 @@ public class PlayerListener extends EventListener
|
|||||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
log("tried to climb a wall.",player,CheckType.SPIDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,48 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat.event;
|
||||||
|
|
||||||
import net.h31ix.anticheat.manage.Backend;
|
import net.h31ix.anticheat.manage.Backend;
|
||||||
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.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
|
||||||
{
|
{
|
||||||
private final Backend backend = getBackend();
|
private final Backend backend = getBackend();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVehicleEnter(VehicleEnterEvent event)
|
public void onVehicleEnter(VehicleEnterEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntered() instanceof Player)
|
if(event.getEntered() instanceof Player)
|
||||||
{
|
{
|
||||||
backend.logEnterExit((Player)event.getEntered());
|
backend.logEnterExit((Player)event.getEntered());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVehicleExit(VehicleExitEvent event)
|
public void onVehicleExit(VehicleExitEvent event)
|
||||||
{
|
{
|
||||||
if(event.getExited() instanceof Player)
|
if(event.getExited() instanceof Player)
|
||||||
{
|
{
|
||||||
backend.logEnterExit((Player)event.getExited());
|
backend.logEnterExit((Player)event.getExited());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,25 +20,65 @@ package net.h31ix.anticheat.manage;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import net.h31ix.anticheat.Configuration;
|
import net.h31ix.anticheat.Configuration;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.h31ix.anticheat.xray.XRayTracker;
|
||||||
|
|
||||||
public final class AnticheatManager
|
public class AnticheatManager
|
||||||
{
|
{
|
||||||
private AnticheatManager()
|
private Anticheat plugin = null;
|
||||||
|
private Configuration CONFIGURATION = null;
|
||||||
|
private XRayTracker XRAY_TRACKER = null;
|
||||||
|
private PlayerManager PLAYER_MANAGER = null;
|
||||||
|
private CheckManager CHECK_MANAGER = null;
|
||||||
|
private Backend BACKEND = null;
|
||||||
|
private Logger LOGGER = null;
|
||||||
|
|
||||||
|
public AnticheatManager(Anticheat instance)
|
||||||
{
|
{
|
||||||
|
plugin = instance;
|
||||||
|
// now load all the others!!!!!
|
||||||
|
CONFIGURATION = new Configuration(this);
|
||||||
|
XRAY_TRACKER = new XRayTracker();
|
||||||
|
PLAYER_MANAGER = new PlayerManager(this);
|
||||||
|
CHECK_MANAGER = new CheckManager(this);
|
||||||
|
BACKEND = new Backend(this);
|
||||||
|
LOGGER = Logger.getLogger("Minecraft");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Configuration CONFIGURATION = new Configuration();
|
public void log(String message)
|
||||||
public static final XRayTracker XRAY_TRACKER = new XRayTracker();
|
|
||||||
public static final PlayerManager PLAYER_MANAGER = new PlayerManager();
|
|
||||||
public static final CheckManager CHECK_MANAGER = new CheckManager();
|
|
||||||
public static final Backend BACKEND = new Backend();
|
|
||||||
private static final Logger ANTICHEAT_LOGGER = Logger.getLogger("Minecraft");
|
|
||||||
|
|
||||||
public static void log(String message)
|
|
||||||
{
|
{
|
||||||
ANTICHEAT_LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Anticheat getPlugin()
|
||||||
|
{
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Configuration getConfiguration()
|
||||||
|
{
|
||||||
|
return CONFIGURATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XRayTracker getXRayTracker()
|
||||||
|
{
|
||||||
|
return XRAY_TRACKER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerManager getPlayerManager()
|
||||||
|
{
|
||||||
|
return PLAYER_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckManager getCheckManager()
|
||||||
|
{
|
||||||
|
return CHECK_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Backend getBackend()
|
||||||
|
{
|
||||||
|
return BACKEND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,9 +22,9 @@ 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;
|
||||||
import net.h31ix.anticheat.Anticheat;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
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.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@@ -41,6 +41,15 @@ public class Backend
|
|||||||
public static final int DAMAGE_TIME = 50;
|
public static final int DAMAGE_TIME = 50;
|
||||||
public static final int KNOCKBACK_DAMAGE_TIME = 50;
|
public static final int KNOCKBACK_DAMAGE_TIME = 50;
|
||||||
|
|
||||||
|
public static final int FASTBREAK_LIMIT = 3;
|
||||||
|
public static final int FASTBREAK_TIMEMAX = 500;
|
||||||
|
public static final int FASTBREAK_MAXVIOLATIONS = 2;
|
||||||
|
public static final int FASTBREAK_MAXVIOLATIONTIME = 10000;
|
||||||
|
public static final int FASTPLACE_LIMIT = 2;
|
||||||
|
public static final int FASTPLACE_TIMEMAX = 20;
|
||||||
|
public static final int FASTPLACE_MAXVIOLATIONS = 1;
|
||||||
|
public static final int FASTPLACE_MAXVIOLATIONTIME = 10000;
|
||||||
|
|
||||||
private static final int CHAT_WARN_LEVEL = 7;
|
private static final int CHAT_WARN_LEVEL = 7;
|
||||||
private static final int CHAT_KICK_LEVEL = 10;
|
private static final int CHAT_KICK_LEVEL = 10;
|
||||||
private static final int CHAT_BAN_LEVEL = 3;
|
private static final int CHAT_BAN_LEVEL = 3;
|
||||||
@@ -71,7 +80,7 @@ public class Backend
|
|||||||
public static final double XZ_SPEED_MAX_WATER = 0.19;
|
public static final double XZ_SPEED_MAX_WATER = 0.19;
|
||||||
public static final double XZ_SPEED_MAX_WATER_SPRINT = 0.3;
|
public static final double XZ_SPEED_MAX_WATER_SPRINT = 0.3;
|
||||||
|
|
||||||
private Anticheat plugin = Anticheat.getPlugin();
|
private AnticheatManager micromanage = null;
|
||||||
private List<String> droppedItem = new ArrayList<String>();
|
private List<String> droppedItem = new ArrayList<String>();
|
||||||
private List<String> animated = new ArrayList<String>();
|
private List<String> animated = new ArrayList<String>();
|
||||||
private List<String> movingExempt = new ArrayList<String>();
|
private List<String> movingExempt = new ArrayList<String>();
|
||||||
@@ -88,6 +97,17 @@ public class Backend
|
|||||||
private Map<String,Integer> chatLevel = new HashMap<String,Integer>();
|
private Map<String,Integer> chatLevel = new HashMap<String,Integer>();
|
||||||
private Map<String,Integer> chatKicks = new HashMap<String,Integer>();
|
private Map<String,Integer> chatKicks = new HashMap<String,Integer>();
|
||||||
private Map<String,Integer> nofallViolation = new HashMap<String,Integer>();
|
private Map<String,Integer> nofallViolation = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Integer> fastBreakViolation = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Integer> blocksBroken = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Long> lastBlockBroken = new HashMap<String,Long>();
|
||||||
|
private Map<String,Integer> fastPlaceViolation = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Integer> blocksPlaced = new HashMap<String,Integer>();
|
||||||
|
private Map<String,Long> lastBlockPlaced = new HashMap<String,Long>();
|
||||||
|
|
||||||
|
public Backend(AnticheatManager instance)
|
||||||
|
{
|
||||||
|
micromanage = instance;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkLongReachBlock(double x,double y,double z)
|
public boolean checkLongReachBlock(double x,double y,double z)
|
||||||
{
|
{
|
||||||
@@ -233,9 +253,26 @@ public class Backend
|
|||||||
}
|
}
|
||||||
if(violation >= FLIGHT_LIMIT)
|
if(violation >= FLIGHT_LIMIT)
|
||||||
{
|
{
|
||||||
|
System.out.println("yep");
|
||||||
flightViolation.put(name, 1);
|
flightViolation.put(name, 1);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
//Start Fly bypass patch.
|
||||||
|
if(flightViolation.containsKey(name) && flightViolation.get(name) > 0)
|
||||||
|
{
|
||||||
|
for(int i= 5;i>0;i--)
|
||||||
|
{
|
||||||
|
System.out.println(i);
|
||||||
|
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ());
|
||||||
|
Block lower = newLocation.getBlock();
|
||||||
|
if(lower.getTypeId() == 0)
|
||||||
|
{
|
||||||
|
player.teleport(newLocation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//End Fly bypass patch.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -248,19 +285,60 @@ public class Backend
|
|||||||
|
|
||||||
public boolean checkFastBreak(Player player, Block block)
|
public boolean checkFastBreak(Player player, Block block)
|
||||||
{
|
{
|
||||||
if(player.getGameMode() != GameMode.CREATIVE && !player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES))
|
String name = player.getName();
|
||||||
|
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES && player.getGameMode() != GameMode.CREATIVE))
|
||||||
{
|
{
|
||||||
if (!justBroke(player))
|
if (!fastBreakViolation.containsKey(name))
|
||||||
{
|
{
|
||||||
logBlockBreak(player);
|
fastBreakViolation.put(name, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||||
|
player.sendMessage(""+math);
|
||||||
|
if(fastBreakViolation.get(name) > FASTBREAK_MAXVIOLATIONS && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||||
|
{
|
||||||
|
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||||
|
{
|
||||||
|
fastBreakViolation.put(name, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name))
|
||||||
|
{
|
||||||
|
if(!lastBlockBroken.containsKey(name))
|
||||||
|
{
|
||||||
|
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
blocksBroken.put(name, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return true;
|
blocksBroken.put(name, blocksBroken.get(name)+1);
|
||||||
|
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||||
|
if(blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX)
|
||||||
|
{
|
||||||
|
blocksBroken.put(name, 0);
|
||||||
|
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||||
|
fastBreakViolation.put(name, fastBreakViolation.get(name)+1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||||
|
{
|
||||||
|
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||||
|
blocksBroken.put(name, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkFastPlace(Player player)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void logBowWindUp(Player player)
|
public void logBowWindUp(Player player)
|
||||||
{
|
{
|
||||||
@@ -425,10 +503,11 @@ public class Backend
|
|||||||
return droppedItem.contains(player.getName());
|
return droppedItem.contains(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logEvent(final List list, final Player player, long time)
|
@SuppressWarnings("unchecked")
|
||||||
|
private void logEvent(@SuppressWarnings("rawtypes") final List list, final Player player, long time)
|
||||||
{
|
{
|
||||||
list.add(player.getName());
|
list.add(player.getName());
|
||||||
Anticheat.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Anticheat.getPlugin(), new Runnable()
|
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@@ -437,10 +516,11 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
private void logEvent(final Map map, final Player player, final Object obj, long time)
|
@SuppressWarnings("unchecked")
|
||||||
|
private void logEvent(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time)
|
||||||
{
|
{
|
||||||
map.put(player,obj);
|
map.put(player,obj);
|
||||||
Anticheat.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Anticheat.getPlugin(), new Runnable()
|
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@@ -473,14 +553,14 @@ public class Backend
|
|||||||
if(chatKicks.get(name) <= CHAT_BAN_LEVEL)
|
if(chatKicks.get(name) <= CHAT_BAN_LEVEL)
|
||||||
{
|
{
|
||||||
player.kickPlayer(ChatColor.RED+"Spamming, kick "+kick+"/3");
|
player.kickPlayer(ChatColor.RED+"Spamming, kick "+kick+"/3");
|
||||||
plugin.getServer().broadcastMessage(ChatColor.RED+player.getName()+" was kicked for spamming.");
|
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was kicked for spamming.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.kickPlayer(ChatColor.RED+"Banned for spamming.");
|
player.kickPlayer(ChatColor.RED+"Banned for spamming.");
|
||||||
player.setBanned(true);
|
player.setBanned(true);
|
||||||
plugin.getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
|
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,9 +31,20 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class CheckManager
|
public class CheckManager
|
||||||
{
|
{
|
||||||
|
public AnticheatManager manager = null;
|
||||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||||
private static Multimap<Player,CheckType> exemptList = ArrayListMultimap.create();
|
private static Multimap<Player,CheckType> exemptList = ArrayListMultimap.create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the class.
|
||||||
|
*
|
||||||
|
* @param instance The AntiCheat Manager
|
||||||
|
*/
|
||||||
|
public CheckManager(AnticheatManager instance)
|
||||||
|
{
|
||||||
|
manager = instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start running a certain check
|
* Start running a certain check
|
||||||
*
|
*
|
||||||
@@ -41,7 +52,7 @@ public class CheckManager
|
|||||||
*/
|
*/
|
||||||
public void activateCheck(CheckType type)
|
public void activateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
AnticheatManager.log("The "+type.toString()+" check was activated.");
|
manager.log("The "+type.toString()+" check was activated.");
|
||||||
checkIgnoreList.remove(type);
|
checkIgnoreList.remove(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +63,7 @@ public class CheckManager
|
|||||||
*/
|
*/
|
||||||
public void deactivateCheck(CheckType type)
|
public void deactivateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
AnticheatManager.log("The "+type.toString()+" check was deactivated.");
|
manager.log("The "+type.toString()+" check was deactivated.");
|
||||||
checkIgnoreList.add(type);
|
checkIgnoreList.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +86,7 @@ public class CheckManager
|
|||||||
*/
|
*/
|
||||||
public void exemptPlayer(Player player, CheckType type)
|
public void exemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
AnticheatManager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
||||||
exemptList.put(player,type);
|
exemptList.put(player,type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +98,7 @@ public class CheckManager
|
|||||||
*/
|
*/
|
||||||
public void unexemptPlayer(Player player, CheckType type)
|
public void unexemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
AnticheatManager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
|
manager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
|
||||||
exemptList.remove(type, type);
|
exemptList.remove(type, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +129,7 @@ public class CheckManager
|
|||||||
public boolean willCheck(Player player, CheckType type)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return isActive(type)
|
return isActive(type)
|
||||||
&& AnticheatManager.CONFIGURATION.checkInWorld(player.getWorld())
|
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !hasPermission(player, type.getPermission());
|
&& !hasPermission(player, type.getPermission());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat.manage;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class Distance
|
public class Distance
|
||||||
{
|
{
|
||||||
private final Location l1,l2;
|
private final Location l1,l2;
|
||||||
|
|
||||||
public Distance(Location from, Location to)
|
public Distance(Location from, Location to)
|
||||||
{
|
{
|
||||||
l1 = to;
|
l1 = to;
|
||||||
l2 = from;
|
l2 = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getXDifference()
|
public double getXDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getX()-l2.getX());
|
return Math.abs(l1.getX()-l2.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZDifference()
|
public double getZDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getZ()-l2.getZ());
|
return Math.abs(l1.getZ()-l2.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYDifference()
|
public double getYDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getY()-l2.getY());
|
return Math.abs(l1.getY()-l2.getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,141 +1,151 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.anticheat.manage;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.h31ix.anticheat.Configuration;
|
|
||||||
import org.bukkit.Bukkit;
|
import net.h31ix.anticheat.Configuration;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
public class PlayerManager {
|
|
||||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
public class PlayerManager {
|
||||||
private static Configuration config = AnticheatManager.CONFIGURATION;
|
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||||
private static final int MED_THRESHOLD = 20;
|
private static Configuration config = null;
|
||||||
private static final int HIGH_THRESHOLD = 50;
|
private static final int MED_THRESHOLD = 20;
|
||||||
|
private static final int HIGH_THRESHOLD = 50;
|
||||||
private static void reactMedium(Player player)
|
|
||||||
{
|
public PlayerManager(AnticheatManager instance) {
|
||||||
execute("Medium",player);
|
config = instance.getConfiguration();
|
||||||
String [] alert = new String[2];
|
}
|
||||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
|
||||||
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
private static void reactMedium(Player player)
|
||||||
Utilities.alert(alert);
|
{
|
||||||
}
|
execute("Medium",player);
|
||||||
private static void reactHigh(Player player)
|
String [] alert = new String[2];
|
||||||
{
|
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
||||||
execute("High",player);
|
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
||||||
String [] alert = new String[2];
|
Utilities.alert(alert);
|
||||||
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
}
|
||||||
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
private static void reactHigh(Player player)
|
||||||
Utilities.alert(alert);
|
{
|
||||||
}
|
execute("High",player);
|
||||||
|
String [] alert = new String[2];
|
||||||
public void increaseLevel(Player player)
|
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
||||||
{
|
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
||||||
final String name = player.getName();
|
Utilities.alert(alert);
|
||||||
if(level.get(name) == null || level.get(name) == 0)
|
}
|
||||||
{
|
|
||||||
level.put(name,1);
|
public void increaseLevel(Player player)
|
||||||
}
|
{
|
||||||
else
|
final String name = player.getName();
|
||||||
{
|
if(level.get(name) == null || level.get(name) == 0)
|
||||||
final int playerLevel = level.get(name);
|
{
|
||||||
level.put(name, playerLevel+1);
|
level.put(name,1);
|
||||||
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
}
|
||||||
{
|
else
|
||||||
reactMedium(player);
|
{
|
||||||
}
|
final int playerLevel = level.get(name);
|
||||||
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
|
level.put(name, playerLevel+1);
|
||||||
{
|
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
||||||
reactHigh(player);
|
{
|
||||||
}
|
reactMedium(player);
|
||||||
}
|
}
|
||||||
}
|
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
|
||||||
|
{
|
||||||
public void decreaseLevel(Player player)
|
reactHigh(player);
|
||||||
{
|
level.put(player.getName(), MED_THRESHOLD+5);
|
||||||
final String name = player.getName();
|
}
|
||||||
if(level.get(name) != null && level.get(name) != 0)
|
else if (playerLevel > HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
int playerLevel = level.get(name)-1;
|
level.put(player.getName(), MED_THRESHOLD+5);
|
||||||
level.put(name, playerLevel);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevel(Player player)
|
public void decreaseLevel(Player player)
|
||||||
{
|
{
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
if(level.get(name) != null)
|
if(level.get(name) != null && level.get(name) != 0)
|
||||||
{
|
{
|
||||||
return level.get(name);
|
int playerLevel = level.get(name)-1;
|
||||||
}
|
level.put(name, playerLevel);
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return 0;
|
|
||||||
}
|
public int getLevel(Player player)
|
||||||
}
|
{
|
||||||
|
final String name = player.getName();
|
||||||
public void setLevel(Player player, int x)
|
if(level.get(name) != null)
|
||||||
{
|
{
|
||||||
level.put(player.getName(), x);
|
return level.get(name);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
public boolean hasLevel(Player player)
|
{
|
||||||
{
|
return 0;
|
||||||
return level.containsKey(player.getName());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(Player player)
|
public void setLevel(Player player, int x)
|
||||||
{
|
{
|
||||||
level.put(player.getName(),0);
|
level.put(player.getName(), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Integer> getLevels()
|
public boolean hasLevel(Player player)
|
||||||
{
|
{
|
||||||
return level;
|
return level.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void execute(String level, Player player)
|
public void reset(Player player)
|
||||||
{
|
{
|
||||||
String result = config.getResult(level);
|
level.put(player.getName(),0);
|
||||||
if(result.startsWith("COMMAND["))
|
}
|
||||||
{
|
|
||||||
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
public Map<String,Integer> getLevels()
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
{
|
||||||
}
|
return level;
|
||||||
else if(result.equalsIgnoreCase("KICK"))
|
}
|
||||||
{
|
|
||||||
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
private static void execute(String level, Player player)
|
||||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
{
|
||||||
}
|
String result = config.getResult(level);
|
||||||
else if(result.equalsIgnoreCase("WARN"))
|
if(result.startsWith("COMMAND["))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
||||||
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("BAN"))
|
else if(result.equalsIgnoreCase("KICK"))
|
||||||
{
|
{
|
||||||
player.setBanned(true);
|
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
||||||
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
||||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
}
|
||||||
}
|
else if(result.equalsIgnoreCase("WARN"))
|
||||||
}
|
{
|
||||||
}
|
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
||||||
|
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
||||||
|
}
|
||||||
|
else if(result.equalsIgnoreCase("BAN"))
|
||||||
|
{
|
||||||
|
player.setBanned(true);
|
||||||
|
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
||||||
|
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -50,7 +53,7 @@ public final class Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(AnticheatManager.CONFIGURATION.logConsole())
|
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
Logger logger = Logger.getLogger("Minecraft");
|
Logger logger = Logger.getLogger("Minecraft");
|
||||||
for(String msg : message)
|
for(String msg : message)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
package net.h31ix.anticheat.xray;
|
package net.h31ix.anticheat.xray;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import net.h31ix.anticheat.Configuration;
|
import net.h31ix.anticheat.Configuration;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
|
||||||
import net.h31ix.anticheat.manage.CheckManager;
|
import net.h31ix.anticheat.manage.CheckManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.h31ix.anticheat.manage.CheckType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -29,9 +29,9 @@ 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 = AnticheatManager.XRAY_TRACKER;
|
private XRayTracker tracker = Anticheat.getManager().getXRayTracker();
|
||||||
private Configuration config = AnticheatManager.CONFIGURATION;
|
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private CheckManager checkManager = AnticheatManager.CHECK_MANAGER;
|
private CheckManager checkManager = Anticheat.getManager().getCheckManager();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
|||||||
@@ -1,109 +1,109 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 H31IX http://h31ix.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.h31ix.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 c = 0;
|
private double c = 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> coal,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> coal,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(coal.get(player) != null)
|
if(coal.get(player) != null)
|
||||||
{
|
{
|
||||||
c = (coal.get(player)/t)*DIVISOR;
|
c = (coal.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 getCoal()
|
public double getCoal()
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,6 @@ public class XRayTracker {
|
|||||||
|
|
||||||
public XRayTracker()
|
public XRayTracker()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sufficientData(String player)
|
public boolean sufficientData(String player)
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#AntiCheat configuration file
|
#AntiCheat configuration file
|
||||||
#Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/
|
#Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/
|
||||||
XRay:
|
XRay:
|
||||||
Log xray stats: true
|
Log xray stats: true
|
||||||
Alert when xray is found: false
|
Alert when xray is found: false
|
||||||
|
|
||||||
Events:
|
Events:
|
||||||
#Valid events = NONE,WARN,KICK,BAN,COMMAND[command]
|
#Valid events = NONE,WARN,KICK,BAN,COMMAND[command]
|
||||||
#Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]
|
#Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]
|
||||||
#&player will be replaced with player's name, and any command on your server can be used.
|
#&player will be replaced with player's name, and any command on your server can be used.
|
||||||
Level Medium: WARN
|
Level Medium: WARN
|
||||||
Level High: KICK
|
Level High: KICK
|
||||||
|
|
||||||
System:
|
System:
|
||||||
#Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so.
|
#Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so.
|
||||||
#AntiCheat will never bother you about updates if this is on, but if you turn it off you will have to manually update.
|
#AntiCheat will never bother you about updates if this is on, but if you turn it off you will have to manually update.
|
||||||
Auto update: true
|
Auto update: true
|
||||||
Log to console: false
|
Log to console: false
|
||||||
Verbose startup: false
|
Verbose startup: false
|
||||||
Reference in new issue
Block a user