mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Merge branch 'master' of github.com:h31ix/AntiCheat into development
Conflicts: src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java src/main/java/net/h31ix/anticheat/manage/CheckType.java
This commit is contained in:
commit
b411e92f44
19 files changed
+570
-209
No files matched your search
@@ -30,9 +30,9 @@ import java.util.logging.Logger;
|
||||
import net.h31ix.anticheat.event.*;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import net.h31ix.anticheat.metrics.Metrics;
|
||||
import net.h31ix.anticheat.metrics.Metrics.Graph;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import net.h31ix.anticheat.xray.XRayListener;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -56,6 +56,7 @@ public class Anticheat extends JavaPlugin
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
AnticheatManager.close();
|
||||
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
||||
Iterator<String> set = map.keySet().iterator();
|
||||
while (set.hasNext())
|
||||
@@ -206,10 +207,10 @@ public class Anticheat extends JavaPlugin
|
||||
logger.log(Level.INFO, "Data for "+player.getName()+" re-applied from flatfile");
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "Finished loading.");
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "Finished loading.");
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile(String file, String url)
|
||||
@@ -249,7 +250,7 @@ public class Anticheat extends JavaPlugin
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
logger.log(Level.INFO,"AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,9 +307,9 @@ public class Anticheat extends JavaPlugin
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (!this.getDescription().getVersion().equalsIgnoreCase(v))
|
||||
String version = this.getDescription().getVersion().split("-b")[0];
|
||||
if (!version.equalsIgnoreCase(v))
|
||||
{
|
||||
String version = this.getDescription().getVersion();
|
||||
if (version.endsWith("-PRE") || version.endsWith("-DEV"))
|
||||
{
|
||||
if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
||||
|
||||
@@ -52,13 +52,11 @@ public class CommandHandler implements CommandExecutor
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
private static final String ADMIN_PERM = "anticheat.admin";
|
||||
private static final String MOD_PERM = "anticheat.mod";
|
||||
private static final String PERMISSIONS_ERROR = RED+"Insufficient Permissions.";
|
||||
|
||||
public void handleLog(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.log") || hasPermission(cs,ADMIN_PERM))
|
||||
if(Permission.SYSTEM_LOG.get(cs))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("enable"))
|
||||
{
|
||||
@@ -97,7 +95,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleXRay(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.xray") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM))
|
||||
if(Permission.SYSTEM_XRAY.get(cs))
|
||||
{
|
||||
if(config.logXRay())
|
||||
{
|
||||
@@ -142,7 +140,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReset(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.reset") || hasPermission(cs,ADMIN_PERM))
|
||||
if(Permission.SYSTEM_RESET.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
@@ -180,7 +178,7 @@ public class CommandHandler implements CommandExecutor
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
Player sender = (Player)cs;
|
||||
if(hasPermission(cs,"system.spy") || hasPermission(cs,MOD_PERM))
|
||||
if(Permission.SYSTEM_SPY.get(cs))
|
||||
{
|
||||
if(!args[1].equalsIgnoreCase("off"))
|
||||
{
|
||||
@@ -236,7 +234,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleHelp(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.help") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM))
|
||||
if(Permission.SYSTEM_HELP.get(cs))
|
||||
{
|
||||
String base = "/AntiCheat ";
|
||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||
@@ -259,7 +257,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleUpdate(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.update") || hasPermission(cs,ADMIN_PERM))
|
||||
if(Permission.SYSTEM_UPDATE.get(cs))
|
||||
{
|
||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
@@ -289,7 +287,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReport(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM))
|
||||
if(Permission.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
getPlayers();
|
||||
if(!low.isEmpty())
|
||||
@@ -325,7 +323,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handlePlayerReport(CommandSender cs,String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM))
|
||||
if(Permission.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
@@ -439,7 +437,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReload(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.reload") || hasPermission(cs,ADMIN_PERM))
|
||||
if(Permission.SYSTEM_RELOAD.get(cs))
|
||||
{
|
||||
config.load();
|
||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
||||
@@ -517,17 +515,6 @@ public class CommandHandler implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender cs, String permission)
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
return ((Player)cs).hasPermission("anticheat."+permission);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void getPlayers()
|
||||
{
|
||||
high.clear();
|
||||
|
||||
@@ -45,6 +45,8 @@ public class Configuration
|
||||
private boolean alertXRay;
|
||||
private boolean autoUpdate;
|
||||
private boolean verboseStartup;
|
||||
private boolean chatSpam;
|
||||
private boolean commandSpam;
|
||||
private int fileLogLevel = 0;
|
||||
private String updateFolder;
|
||||
private static Language language;
|
||||
@@ -97,6 +99,16 @@ public class Configuration
|
||||
return verboseStartup;
|
||||
}
|
||||
|
||||
public boolean chatSpam()
|
||||
{
|
||||
return chatSpam;
|
||||
}
|
||||
|
||||
public boolean commandSpam()
|
||||
{
|
||||
return commandSpam;
|
||||
}
|
||||
|
||||
public String updateFolder()
|
||||
{
|
||||
return updateFolder;
|
||||
@@ -140,7 +152,7 @@ public class Configuration
|
||||
config.set("Enable in", w);
|
||||
save();
|
||||
}
|
||||
worlds = (List<String>)(config.getList("Enable in"));
|
||||
worlds = config.getStringList("Enable in");
|
||||
if(config.getString("XRay.Log xray stats") == null)
|
||||
{
|
||||
config.set("XRay.Log xray stats", true);
|
||||
@@ -170,7 +182,19 @@ public class Configuration
|
||||
config.set("System.File log level", 1);
|
||||
save();
|
||||
}
|
||||
fileLogLevel = config.getInt("System.File log level");
|
||||
fileLogLevel = config.getInt("System.File log level");
|
||||
if(config.getString("System.Block chat spam") == null)
|
||||
{
|
||||
config.set("System.Block chat spam", true);
|
||||
save();
|
||||
}
|
||||
chatSpam = config.getBoolean("System.Block chat spam");
|
||||
if(config.getString("System.Block command spam") == null)
|
||||
{
|
||||
config.set("System.Block command spam", true);
|
||||
save();
|
||||
}
|
||||
commandSpam = config.getBoolean("System.Block command spam");
|
||||
}
|
||||
|
||||
public String getResult(String event)
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class Language
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum Permission
|
||||
{
|
||||
/* Check Nodes */
|
||||
CHECK_ZOMBE_FLY,
|
||||
CHECK_ZOMBE_NOCLIP,
|
||||
CHECK_ZOMBE_CHEAT,
|
||||
CHECK_FLY,
|
||||
CHECK_WATERWALK,
|
||||
CHECK_NOSWING,
|
||||
CHECK_FASTBREAK,
|
||||
CHECK_FASTPLACE,
|
||||
CHECK_SPAM,
|
||||
CHECK_SPRINT,
|
||||
CHECK_SNEAK,
|
||||
CHECK_SPEED,
|
||||
CHECK_SPIDER,
|
||||
CHECK_NOFALL,
|
||||
CHECK_FASTBOW,
|
||||
CHECK_FASTEAT,
|
||||
CHECK_FASTHEAL,
|
||||
CHECK_FORCEFIELD,
|
||||
CHECK_XRAY,
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
SYSTEM_XRAY,
|
||||
SYSTEM_RESET,
|
||||
SYSTEM_SPY,
|
||||
SYSTEM_HELP,
|
||||
SYSTEM_UPDATE,
|
||||
SYSTEM_REPORT,
|
||||
SYSTEM_RELOAD;
|
||||
|
||||
public boolean get(CommandSender cs)
|
||||
{
|
||||
return cs.hasPermission(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class AnticheatAPI
|
||||
*/
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
return chk.willCheck(player, type);
|
||||
return chk.willCheck(player, type);
|
||||
}
|
||||
|
||||
//PlayerManager API
|
||||
|
||||
@@ -47,9 +47,9 @@ public class EventListener implements Listener
|
||||
{
|
||||
USAGE_LIST.put(type, getCheats(type)+1);
|
||||
type.logUse(player);
|
||||
if(PLUGIN.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||
if(Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||
{
|
||||
PLUGIN.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks.");
|
||||
Anticheat.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ public class EventListener implements Listener
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
public static AnticheatManager getManager()
|
||||
{
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
@@ -40,15 +42,21 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
public class PlayerListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
private final Configuration config = Anticheat.getManager().getConfiguration();
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.SPAM))
|
||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
||||
{
|
||||
backend.logChat(player);
|
||||
if(backend.checkSpam(player, event.getMessage()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"Please do not spam.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,11 +98,29 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler
|
||||
public void onPlayerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY)) //@h31ix: Change if necessary. I'm not sure what perms should go here :3
|
||||
{
|
||||
if(backend.justVelocity(player))
|
||||
{
|
||||
if(backend.extendVelocityTime(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return; // don't log it lol.
|
||||
}
|
||||
}
|
||||
backend.logVelocity(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.SPAM))
|
||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
||||
{
|
||||
backend.logChat(player);
|
||||
if(backend.checkSpam(player, event.getMessage()))
|
||||
@@ -237,48 +263,21 @@ public class PlayerListener extends EventListener
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
backend.checkAscension(player,from.getY(),to.getY());
|
||||
backend.logAscension(player,from.getY(),to.getY());
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
from.setY(from.getY()-1);
|
||||
from.setZ(from.getZ()-1);
|
||||
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 newBlock = newLocation.getBlock();
|
||||
if(newBlock.getTypeId() != 0)
|
||||
{
|
||||
event.setTo(newLocation);
|
||||
}
|
||||
Block lower = player.getWorld().getHighestBlockAt(from);
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly.",player,CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkYAxis(player, distance))
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player,from.getY(),to.getY())))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
from.setY(from.getY()-1);
|
||||
from.setZ(from.getZ()-1);
|
||||
if(from.getBlock().getTypeId() == 0)
|
||||
{
|
||||
event.setTo(from);
|
||||
}
|
||||
for(int i= 5;i>0;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;
|
||||
}
|
||||
}
|
||||
//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 newBlock = newLocation.getBlock();
|
||||
if(newBlock.getTypeId() != 0)
|
||||
{
|
||||
event.setTo(newLocation);
|
||||
}
|
||||
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
@@ -286,7 +285,7 @@ public class PlayerListener extends EventListener
|
||||
if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to ascend to fast.",player,CheckType.SPEED);
|
||||
log("tried to ascend too fast.",player,CheckType.SPEED);
|
||||
}
|
||||
if(backend.checkXZSpeed(player,x,z))
|
||||
{
|
||||
@@ -300,31 +299,34 @@ public class PlayerListener extends EventListener
|
||||
log("tried avoid fall damage.",player,CheckType.NOFALL);
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void checkSpeed(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
Distance distance = new Distance(from, to);
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
if(checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player,x,z))
|
||||
Location to = event.getTo();
|
||||
if(event.getTo() != event.getFrom())
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
||||
{
|
||||
event.setTo(from);
|
||||
player.setSneaking(false);
|
||||
log("tried to sneak too fast.",player,CheckType.SNEAK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
||||
}
|
||||
Distance distance = new Distance(from, to);
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
if(checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player,x,z))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
||||
{
|
||||
event.setTo(from);
|
||||
player.setSneaking(false);
|
||||
log("tried to sneak too fast.",player,CheckType.SNEAK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,9 @@
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.*;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.util.ConsoleFormatter;
|
||||
import net.h31ix.anticheat.util.FileFormatter;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -42,15 +40,15 @@ public class AnticheatManager
|
||||
private CheckManager checkManager = null;
|
||||
private Backend backend = null;
|
||||
private static Logger LOGGER, FILE_LOGGER;
|
||||
private static Handler handler;
|
||||
private static Handler fileHandler;
|
||||
private static final int LOG_LEVEL_HIGH = 3;
|
||||
|
||||
public AnticheatManager(Anticheat instance)
|
||||
{
|
||||
plugin = instance;
|
||||
// now load all the others!!!!!
|
||||
LOGGER = plugin.getAnticheatLogger();
|
||||
FILE_LOGGER = LOGGER;
|
||||
LOGGER = Logger.getLogger("Minecraft");
|
||||
FILE_LOGGER = Logger.getLogger("Minecraft");
|
||||
configuration = new Configuration(this);
|
||||
xrayTracker = new XRayTracker();
|
||||
playerManager = new PlayerManager(this);
|
||||
@@ -63,27 +61,20 @@ public class AnticheatManager
|
||||
{
|
||||
file.mkdir();
|
||||
}
|
||||
handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
||||
handler.setFormatter(new FileFormatter());
|
||||
handler.setLevel(Level.INFO);
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
fileHandler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log",true);
|
||||
fileHandler.setFormatter(new FileFormatter());
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
FILE_LOGGER.setUseParentHandlers(false);
|
||||
FILE_LOGGER.addHandler(handler);
|
||||
LOGGER.setUseParentHandlers(false);
|
||||
Handler chandler = new ConsoleHandler();
|
||||
chandler.setFormatter(new ConsoleFormatter());
|
||||
LOGGER.addHandler(chandler);
|
||||
FILE_LOGGER.addHandler(fileHandler);
|
||||
}
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
if(getConfiguration().logConsole())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
LOGGER.info("[AntiCheat] "+ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
}
|
||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||
{
|
||||
@@ -93,7 +84,7 @@ public class AnticheatManager
|
||||
|
||||
public void fileLog(String message)
|
||||
{
|
||||
FILE_LOGGER.log(Level.WARNING, message);
|
||||
FILE_LOGGER.info(message);
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
@@ -125,4 +116,8 @@ public class AnticheatManager
|
||||
{
|
||||
return backend;
|
||||
}
|
||||
public static void close()
|
||||
{
|
||||
fileHandler.close();
|
||||
}
|
||||
}
|
||||
@@ -70,8 +70,14 @@ public class Backend
|
||||
private static final int FLIGHT_LIMIT = 4;
|
||||
private static final int Y_MAXVIOLATIONS = 1;
|
||||
private static final int Y_MAXVIOTIME = 5000;
|
||||
private static final int VELOCITY_TIME = 60;
|
||||
private static final long VELOCITY_SCHETIME = 2;
|
||||
private static final long VELOCITY_CHECKTIME = 2100;
|
||||
private static final long VELOCITY_PREVENT = 5000;
|
||||
private static final int VELOCITY_MAXTIMES = 2;
|
||||
private static final int NOFALL_LIMIT = 5;
|
||||
|
||||
private static final int ASCENSION_COUNT_MAX = 8;
|
||||
private static final int WATER_ASCENSION_VIOLATION_MAX = 13;
|
||||
private static final int WATER_SPEED_VIOLATION_MAX = 4;
|
||||
|
||||
@@ -80,6 +86,7 @@ public class Backend
|
||||
private static final int HEAL_MIN = 35;
|
||||
private static final int ANIMATION_MIN = 60;
|
||||
private static final int CHAT_MIN = 100;
|
||||
private static final int CHAT_REPEAT_MIN = 260;
|
||||
private static final int BOW_MIN = 2;
|
||||
private static final int SPRINT_MIN = 2;
|
||||
private static final int BLOCK_BREAK_MIN = 1;
|
||||
@@ -106,7 +113,6 @@ public class Backend
|
||||
|
||||
private AnticheatManager micromanage = null;
|
||||
private List<String> droppedItem = new ArrayList<String>();
|
||||
private List<String> animated = new ArrayList<String>();
|
||||
private List<String> movingExempt = new ArrayList<String>();
|
||||
private List<String> brokenBlock = new ArrayList<String>();
|
||||
private List<String> placedBlock = new ArrayList<String>();
|
||||
@@ -119,6 +125,8 @@ public class Backend
|
||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||
private List<String> isAscending = new ArrayList<String>();
|
||||
private List<String> trackingProjectiles = new ArrayList<String>();
|
||||
private List<String> velocitizing = new ArrayList<String>();
|
||||
private Map<String,Integer> ascensionCount = new HashMap<String,Integer>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||
@@ -140,6 +148,9 @@ public class Backend
|
||||
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> projectilesShot = new HashMap<String,Integer>();
|
||||
private Map<String,Long> velocitized = new HashMap<String,Long>();
|
||||
private Map<String,Integer> velocitytrack = new HashMap<String,Integer>();
|
||||
private Map<String,Location> animated = new HashMap<String,Location>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
@@ -158,7 +169,7 @@ public class Backend
|
||||
|
||||
public boolean checkSpider(Player player,double y)
|
||||
{
|
||||
if(y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER)
|
||||
if(y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && !Utilities.isOnLadder(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -167,7 +178,7 @@ public class Backend
|
||||
|
||||
public boolean checkYSpeed(Player player,double y)
|
||||
{
|
||||
if(/*!player.isFlying() &&*/ player.getVehicle() == null && y > Y_SPEED_MAX)
|
||||
if(!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player) && !player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -217,17 +228,17 @@ public class Backend
|
||||
{
|
||||
return x > XZ_SPEED_MAX_FLY || z > XZ_SPEED_MAX_FLY;
|
||||
}
|
||||
if(!player.isSprinting())
|
||||
{
|
||||
return x > XZ_SPEED_MAX || z > XZ_SPEED_MAX;
|
||||
}
|
||||
else if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
{
|
||||
return x > XZ_SPEED_MAX_POTION || z > XZ_SPEED_MAX_POTION;
|
||||
}
|
||||
else if(player.isSprinting())
|
||||
{
|
||||
return x > XZ_SPEED_MAX_SPRINT || z > XZ_SPEED_MAX_SPRINT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x > XZ_SPEED_MAX_SPRINT || z > XZ_SPEED_MAX_SPRINT;
|
||||
return x > XZ_SPEED_MAX || z > XZ_SPEED_MAX;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -377,7 +388,7 @@ public class Backend
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!isMovingExempt(player))
|
||||
if(!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle() && !Utilities.isInWater(player))
|
||||
{
|
||||
double y1 = player.getLocation().getY();
|
||||
String name = player.getName();
|
||||
@@ -400,7 +411,7 @@ public class Backend
|
||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
player.teleport(g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -420,7 +431,7 @@ public class Backend
|
||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
player.teleport(g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -448,10 +459,10 @@ public class Backend
|
||||
double y1 = distance.fromY();
|
||||
double y2 = distance.toY();
|
||||
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
if(y1 == y2 && !isMovingExempt(player) && player.getVehicle() == null && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player))
|
||||
if(y1 == y2 && !isMovingExempt(player) && !player.isInsideVehicle() && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player))
|
||||
{
|
||||
String name = player.getName();
|
||||
if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && !Utilities.canStand(player.getLocation().getBlock()) && !Utilities.isSubmersed(player))
|
||||
if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isInWater(player))
|
||||
{
|
||||
int violation = 1;
|
||||
if(!flightViolation.containsKey(name))
|
||||
@@ -488,16 +499,47 @@ public class Backend
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkAscension(Player player, double y1, double y2)
|
||||
public void logAscension(Player player, double y1, double y2)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
{
|
||||
isAscending.add(player.getName());
|
||||
isAscending.add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
isAscending.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkAscension(Player player, double y1, double y2)
|
||||
{
|
||||
int max = ASCENSION_COUNT_MAX;
|
||||
if(player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
{
|
||||
max+=12;
|
||||
}
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle())
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
{
|
||||
if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid())
|
||||
{
|
||||
increment(player, ascensionCount, max);
|
||||
if(ascensionCount.get(name) >= max)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ascensionCount.put(name,0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkSwing(Player player, Block block)
|
||||
@@ -679,7 +721,7 @@ public class Backend
|
||||
else
|
||||
{
|
||||
int amount = chatLevel.get(name)+1;
|
||||
chatLevel.put(name, amount);
|
||||
logEvent(chatLevel,player,amount,CHAT_MIN);
|
||||
checkChatLevel(player, amount);
|
||||
}
|
||||
}
|
||||
@@ -689,7 +731,8 @@ public class Backend
|
||||
String name = player.getName();
|
||||
if(lastMessage.get(name) == null)
|
||||
{
|
||||
lastMessage.put(name, msg);
|
||||
logEvent(lastMessage,player,msg,CHAT_REPEAT_MIN);
|
||||
//lastMessage.put(name, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -699,8 +742,10 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
oldMessage.put(name, lastMessage.get(name));
|
||||
lastMessage.put(name, msg);
|
||||
logEvent(oldMessage,player,lastMessage.get(name),CHAT_REPEAT_MIN);
|
||||
//oldMessage.put(name, lastMessage.get(name));
|
||||
logEvent(oldMessage,player,msg,CHAT_REPEAT_MIN);
|
||||
//lastMessage.put(name, msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -741,7 +786,49 @@ public class Backend
|
||||
public boolean justBroke(Player player)
|
||||
{
|
||||
return brokenBlock.contains(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void logVelocity(final Player player)
|
||||
{
|
||||
logEvent(velocitizing,player,VELOCITY_TIME);
|
||||
velocitized.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean justVelocity(Player player)
|
||||
{
|
||||
return isVelocity(player) || (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < VELOCITY_CHECKTIME : false);
|
||||
}
|
||||
|
||||
public boolean isVelocity(Player player)
|
||||
{
|
||||
return velocitizing.contains(player.getName());
|
||||
}
|
||||
|
||||
public boolean extendVelocityTime(final Player player)
|
||||
{
|
||||
if(velocitytrack.containsKey(player.getName()))
|
||||
{
|
||||
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
|
||||
if(velocitytrack.get(player.getName()) > VELOCITY_MAXTIMES) {
|
||||
velocitized.put(player.getName(), System.currentTimeMillis() + VELOCITY_PREVENT);
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
}
|
||||
}, VELOCITY_SCHETIME * 20L);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void logBlockPlace(final Player player)
|
||||
{
|
||||
@@ -755,7 +842,7 @@ public class Backend
|
||||
|
||||
public void logAnimation(final Player player)
|
||||
{
|
||||
logEvent(animated,player,ANIMATION_MIN);
|
||||
logEvent(animated,player,player.getLocation(),ANIMATION_MIN);
|
||||
increment(player,blockPunches,BLOCK_PUNCH_MIN);
|
||||
}
|
||||
|
||||
@@ -767,7 +854,7 @@ public class Backend
|
||||
|
||||
public boolean justAnimated(Player player)
|
||||
{
|
||||
return animated.contains(player.getName());
|
||||
return animated.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void logProjectile(final Player player, final EventListener e)
|
||||
@@ -837,7 +924,7 @@ public class Backend
|
||||
|
||||
public boolean isMovingExempt(Player player)
|
||||
{
|
||||
return movingExempt.contains(player.getName()) || player.isFlying();
|
||||
return movingExempt.contains(player.getName()) || player.isFlying() || isVelocity(player);
|
||||
}
|
||||
|
||||
public boolean isAscending(Player player)
|
||||
@@ -845,8 +932,9 @@ public class Backend
|
||||
return isAscending.contains(player.getName());
|
||||
}
|
||||
|
||||
public boolean isSpeedExempt(Player player) {
|
||||
return movingExempt.contains(player.getName());
|
||||
public boolean isSpeedExempt(Player player)
|
||||
{
|
||||
return movingExempt.contains(player.getName()) || isVelocity(player);
|
||||
}
|
||||
|
||||
public void logDroppedItem(final Player player)
|
||||
@@ -876,16 +964,23 @@ public class Backend
|
||||
@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.getName(),obj);
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
map.remove(player);
|
||||
if(map.get(player.getName()) == obj)
|
||||
{
|
||||
map.remove(player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Don't remove this, for some reason it's fixing chat bugs.
|
||||
}
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
}
|
||||
private void checkChatLevel(Player player, int amount)
|
||||
{
|
||||
if(amount >= CHAT_WARN_LEVEL)
|
||||
|
||||
@@ -84,17 +84,12 @@ public class CheckManager
|
||||
return exemptList.containsEntry(player.getName(), type);
|
||||
}
|
||||
|
||||
private boolean hasPermission(Player player, String permission)
|
||||
{
|
||||
return player.hasPermission(permission) || player.hasPermission("anticheat.exempt");
|
||||
}
|
||||
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
return isActive(type)
|
||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||
&& !isExempt(player, type)
|
||||
&& !hasPermission(player, type.getPermission());
|
||||
&& !type.checkPermission(player);
|
||||
}
|
||||
|
||||
public int getExempt()
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -31,41 +32,40 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public enum CheckType
|
||||
{
|
||||
ZOMBE_FLY("anticheat.zombe.fly"),
|
||||
ZOMBE_NOCLIP("anticheat.zombe.noclip"),
|
||||
ZOMBE_CHEAT("anticheat.zombe.cheat"),
|
||||
FLY("anticheat.fly"),
|
||||
WATER_WALK("anticheat.waterwalk"),
|
||||
NO_SWING("anticheat.noswing"),
|
||||
FAST_BREAK("anticheat.fastbreak"),
|
||||
INTERACTION("anticheat.interaction"),
|
||||
FAST_PLACE("anticheat.fastplace"),
|
||||
SPAM("anticheat.spam"),
|
||||
SPRINT("anticheat.sprint"),
|
||||
SNEAK("anticheat.sneak"),
|
||||
SPEED("anticheat.speed"),
|
||||
SPIDER("anticheat.spider"),
|
||||
NOFALL("anticheat.nofall"),
|
||||
FAST_BOW("anticheat.fastbow"),
|
||||
FAST_EAT("anticheat.fasteat"),
|
||||
FAST_HEAL("anticheat.fastheal"),
|
||||
FORCEFIELD("anticheat.forcefield"),
|
||||
XRAY("anticheat.xray"),
|
||||
LONG_REACH("anticheat.longreach"),
|
||||
FAST_PROJECTILE("anticheat.projectile"),
|
||||
ITEM_SPAM("anticheat.itemspam");
|
||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
||||
FLY(Permission.CHECK_FLY),
|
||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
||||
NO_SWING(Permission.CHECK_NOSWING),
|
||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
||||
SPAM(Permission.CHECK_SPAM),
|
||||
SPRINT(Permission.CHECK_SPRINT),
|
||||
SNEAK(Permission.CHECK_SNEAK),
|
||||
SPEED(Permission.CHECK_SPEED),
|
||||
SPIDER(Permission.CHECK_SPIDER),
|
||||
NOFALL(Permission.CHECK_NOFALL),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||
XRAY(Permission.CHECK_XRAY),
|
||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM);
|
||||
|
||||
private final String permission;
|
||||
private final Permission permission;
|
||||
private final Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
|
||||
private CheckType(String permission)
|
||||
private CheckType(Permission perm)
|
||||
{
|
||||
this.permission = permission;
|
||||
this.permission = perm;
|
||||
}
|
||||
|
||||
public String getPermission()
|
||||
public boolean checkPermission(Player player)
|
||||
{
|
||||
return this.permission;
|
||||
return permission.get(player);
|
||||
}
|
||||
|
||||
public void logUse(Player player)
|
||||
|
||||
@@ -213,10 +213,10 @@ public class Metrics {
|
||||
private void postPlugin(boolean isPing) throws IOException {
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
|
||||
// Construct the post data
|
||||
String data = encode("guid") + '=' + encode(guid)
|
||||
+ encodeDataPair("version", description.getVersion())
|
||||
+ encodeDataPair("version", description.getVersion().split("-b")[0])
|
||||
+ encodeDataPair("server", Bukkit.getVersion())
|
||||
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
|
||||
+ encodeDataPair("revision", String.valueOf(REVISION));
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.util;
|
||||
|
||||
import java.util.logging.Formatter;
|
||||
@@ -6,10 +24,9 @@ import java.util.logging.LogRecord;
|
||||
public class ConsoleFormatter extends Formatter {
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder output = new StringBuilder()
|
||||
.append(record.getMessage()).append(' ');
|
||||
public String format(LogRecord record)
|
||||
{
|
||||
StringBuilder output = new StringBuilder().append(record.getMessage()).append(' ');
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@@ -13,14 +31,20 @@ public class FileFormatter extends Formatter {
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder output = new StringBuilder()
|
||||
.append("[")
|
||||
.append(record.getLevel()).append('|')
|
||||
.append(format.format(new Date(record.getMillis())))
|
||||
.append("]: ")
|
||||
.append(record.getMessage()).append(' ')
|
||||
.append(lineSep);
|
||||
return output.toString();
|
||||
if(record.getMessage().startsWith("[AntiCheat]"))
|
||||
{
|
||||
StringBuilder output = new StringBuilder()
|
||||
.append("[")
|
||||
.append(record.getLevel()).append('|')
|
||||
.append(format.format(new Date(record.getMillis())))
|
||||
.append("]: ")
|
||||
.append(record.getMessage()).append(' ')
|
||||
.append(lineSep);
|
||||
return output.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,16 +42,10 @@ public final class Utilities
|
||||
}
|
||||
public static void alert(String [] message)
|
||||
{
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers())
|
||||
for(String msg : message)
|
||||
{
|
||||
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.hasPermission("anticheat.mod") || p.isOp())
|
||||
{
|
||||
for(String msg : message)
|
||||
{
|
||||
p.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
Bukkit.broadcast(msg, "anticheat.alert");
|
||||
}
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
for(String msg : message)
|
||||
@@ -103,7 +97,7 @@ public final class Utilities
|
||||
boolean b = false;
|
||||
if(player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
||||
{
|
||||
if(mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK))
|
||||
if(mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING))
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
@@ -181,6 +175,14 @@ public final class Utilities
|
||||
{
|
||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||
}
|
||||
public static boolean isInWater(Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||
}
|
||||
public static boolean isOnLadder(Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
||||
}
|
||||
public static boolean isInt(String string)
|
||||
{
|
||||
boolean x = false;
|
||||
|
||||
Reference in new issue
Block a user