mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Better file logging options
This commit is contained in:
1 parent
de762de1ba
commit
33dfb97a1b
10 files changed
+151
-22
No files matched your search
@@ -19,11 +19,14 @@
|
|||||||
package net.h31ix.anticheat;
|
package net.h31ix.anticheat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
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.Location;
|
||||||
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;
|
||||||
@@ -39,9 +42,10 @@ public class CommandHandler implements CommandExecutor
|
|||||||
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<String> high = new ArrayList<String>();
|
||||||
private List<Player> med = new ArrayList<Player>();
|
private List<String> med = new ArrayList<String>();
|
||||||
private List<Player> low = new ArrayList<Player>();
|
private List<String> low = new ArrayList<String>();
|
||||||
|
private Map<String,Location> spyLocation = new HashMap<String,Location>();
|
||||||
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;
|
||||||
@@ -131,11 +135,11 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if(low.contains(player))
|
if(low.contains(player.getName()))
|
||||||
{
|
{
|
||||||
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.getName()) || high.contains(player.getName()))
|
||||||
{
|
{
|
||||||
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.");
|
||||||
@@ -154,6 +158,61 @@ public class CommandHandler implements CommandExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleSpy(CommandSender cs, String [] args)
|
||||||
|
{
|
||||||
|
if(cs instanceof Player)
|
||||||
|
{
|
||||||
|
Player sender = (Player)cs;
|
||||||
|
if(hasPermission(cs,"system.spy") || hasPermission(cs,"mod"))
|
||||||
|
{
|
||||||
|
if(!args[1].equalsIgnoreCase("off"))
|
||||||
|
{
|
||||||
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
|
if(list.size() == 1)
|
||||||
|
{
|
||||||
|
Player player = list.get(0);
|
||||||
|
for(Player p : cs.getServer().getOnlinePlayers())
|
||||||
|
{
|
||||||
|
p.hidePlayer(sender);
|
||||||
|
}
|
||||||
|
sender.setAllowFlight(true);
|
||||||
|
sender.setFlying(true);
|
||||||
|
spyLocation.put(sender.getName(), sender.getLocation());
|
||||||
|
sender.teleport(player);
|
||||||
|
sender.sendMessage(GREEN+"You have been teleported to "+player.getName()+" and made invisible.");
|
||||||
|
sender.sendMessage(GREEN+"To stop spying, type "+WHITE+" /AntiCheat spy off");
|
||||||
|
}
|
||||||
|
else if(list.size() > 1)
|
||||||
|
{
|
||||||
|
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.setFlying(false);
|
||||||
|
sender.setAllowFlight(false);
|
||||||
|
if(spyLocation.containsKey(sender.getName()))
|
||||||
|
{
|
||||||
|
sender.teleport(spyLocation.get(sender.getName()));
|
||||||
|
spyLocation.remove(sender.getName());
|
||||||
|
}
|
||||||
|
for(Player p : cs.getServer().getOnlinePlayers())
|
||||||
|
{
|
||||||
|
p.showPlayer(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cs.sendMessage(RED+"Sorry, but you can't spy on a player from the console.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handleHelp(CommandSender cs)
|
public void handleHelp(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||||
@@ -205,25 +264,25 @@ public class CommandHandler implements CommandExecutor
|
|||||||
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(String string : low)
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+player.getName());
|
cs.sendMessage(GREEN+string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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(String string : med)
|
||||||
{
|
{
|
||||||
cs.sendMessage(YELLOW+player.getName());
|
cs.sendMessage(YELLOW+string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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(String string : high)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+player.getName());
|
cs.sendMessage(RED+string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,6 +314,10 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
handleReset(cs,args);
|
handleReset(cs,args);
|
||||||
}
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("spy"))
|
||||||
|
{
|
||||||
|
handleSpy(cs,args);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command.");
|
cs.sendMessage(RED+"Unrecognized command.");
|
||||||
@@ -319,15 +382,15 @@ public class CommandHandler implements CommandExecutor
|
|||||||
int level = playerManager.getLevel(player);
|
int level = playerManager.getLevel(player);
|
||||||
if(level <= MED_THRESHOLD)
|
if(level <= MED_THRESHOLD)
|
||||||
{
|
{
|
||||||
low.add(player);
|
low.add(player.getName());
|
||||||
}
|
}
|
||||||
else if(level <= HIGH_THRESHOLD)
|
else if(level <= HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
med.add(player);
|
med.add(player.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
high.add(player);
|
high.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class Configuration
|
|||||||
private boolean alertXRay;
|
private boolean alertXRay;
|
||||||
private boolean autoUpdate;
|
private boolean autoUpdate;
|
||||||
private boolean verboseStartup;
|
private boolean verboseStartup;
|
||||||
|
private int fileLogLevel = 0;
|
||||||
private String updateFolder;
|
private String updateFolder;
|
||||||
private List<String> worlds = new ArrayList<String>();
|
private List<String> worlds = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -100,6 +101,11 @@ public class Configuration
|
|||||||
return updateFolder;
|
return updateFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFileLogLevel()
|
||||||
|
{
|
||||||
|
return fileLogLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public final void load()
|
public final void load()
|
||||||
{
|
{
|
||||||
micromanage.getPlugin().checkConfig();
|
micromanage.getPlugin().checkConfig();
|
||||||
@@ -150,6 +156,12 @@ public class Configuration
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
alertXRay = config.getBoolean("XRay.Alert when xray is found");
|
alertXRay = config.getBoolean("XRay.Alert when xray is found");
|
||||||
|
if(config.getString("System.File log level") == null)
|
||||||
|
{
|
||||||
|
config.set("System.File log level", 1);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
fileLogLevel = config.getInt("System.File log level");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResult(String event)
|
public String getResult(String event)
|
||||||
|
|||||||
@@ -40,12 +40,17 @@ public class EventListener implements Listener
|
|||||||
Anticheat.getManager().log(player.getName()+" "+message);
|
Anticheat.getManager().log(player.getName()+" "+message);
|
||||||
PLAYER_MANAGER.increaseLevel(player);
|
PLAYER_MANAGER.increaseLevel(player);
|
||||||
removeDecrease(player);
|
removeDecrease(player);
|
||||||
logCheat(type);
|
logCheat(type,player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCheat(CheckType type)
|
private void logCheat(CheckType type,Player player)
|
||||||
{
|
{
|
||||||
usageList.put(type, getCheats(type)+1);
|
usageList.put(type, getCheats(type)+1);
|
||||||
|
type.logUse(player);
|
||||||
|
if(PLUGIN.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||||
|
{
|
||||||
|
PLUGIN.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCheck(CheckType type)
|
public void resetCheck(CheckType type)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ 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.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
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;
|
||||||
|
|||||||
@@ -82,6 +82,14 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||||
}
|
}
|
||||||
|
if(getConfiguration().getFileLogLevel() == 3)
|
||||||
|
{
|
||||||
|
fileLog(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fileLog(String message)
|
||||||
|
{
|
||||||
FILE_LOGGER.log(Level.WARNING, message);
|
FILE_LOGGER.log(Level.WARNING, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
package net.h31ix.anticheat.manage;
|
package net.h31ix.anticheat.manage;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -50,6 +54,7 @@ public enum CheckType
|
|||||||
ITEM_SPAM("anticheat.itemspam");
|
ITEM_SPAM("anticheat.itemspam");
|
||||||
|
|
||||||
private final String permission;
|
private final String permission;
|
||||||
|
private static final Map<String,Integer> level = new HashMap<String,Integer>();
|
||||||
|
|
||||||
private CheckType(String permission)
|
private CheckType(String permission)
|
||||||
{
|
{
|
||||||
@@ -60,4 +65,28 @@ public enum CheckType
|
|||||||
{
|
{
|
||||||
return this.permission;
|
return this.permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logUse(Player player)
|
||||||
|
{
|
||||||
|
String name = player.getName();
|
||||||
|
if(level.get(name) == null)
|
||||||
|
{
|
||||||
|
level.put(name, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int amount = level.get(name)+1;
|
||||||
|
level.put(name, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUses(Player player)
|
||||||
|
{
|
||||||
|
int use = 0;
|
||||||
|
if(level.get(player.getName()) != null)
|
||||||
|
{
|
||||||
|
use = level.get(player.getName());
|
||||||
|
}
|
||||||
|
return use;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -45,11 +45,11 @@ public class PlayerManager
|
|||||||
|
|
||||||
private static void reactMedium(Player player)
|
private static void reactMedium(Player player)
|
||||||
{
|
{
|
||||||
execute("Medium",player);
|
execute("Medium",player);
|
||||||
String [] alert = new String[2];
|
String [] alert = new String[2];
|
||||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
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!";
|
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
||||||
Utilities.alert(alert);
|
Utilities.alert(alert);
|
||||||
}
|
}
|
||||||
private static void reactHigh(Player player)
|
private static void reactHigh(Player player)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class Utilities
|
|||||||
{
|
{
|
||||||
for(Player p : Bukkit.getServer().getOnlinePlayers())
|
for(Player p : Bukkit.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.isOp())
|
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.hasPermission("anticheat.mod") || p.isOp())
|
||||||
{
|
{
|
||||||
for(String msg : message)
|
for(String msg : message)
|
||||||
{
|
{
|
||||||
@@ -61,6 +61,13 @@ public final class Utilities
|
|||||||
logger.log(Level.INFO,ChatColor.stripColor(msg));
|
logger.log(Level.INFO,ChatColor.stripColor(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(Anticheat.getManager().getConfiguration().getFileLogLevel() > 0)
|
||||||
|
{
|
||||||
|
for(String msg : message)
|
||||||
|
{
|
||||||
|
Anticheat.getManager().fileLog(ChatColor.stripColor(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static boolean cantStandAt(Block block)
|
public static boolean cantStandAt(Block block)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ System:
|
|||||||
#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
|
||||||
|
#Should AntiCheat log to files?
|
||||||
|
#0 = off, 1 = log when an event takes place, 2 = more detailed logs, 3 = most detailed logs
|
||||||
|
File log level: 1
|
||||||
Verbose startup: false
|
Verbose startup: false
|
||||||
@@ -11,3 +11,4 @@ commands:
|
|||||||
anticheat:
|
anticheat:
|
||||||
description: Control and view info about AntiCheat
|
description: Control and view info about AntiCheat
|
||||||
usage: /anticheat help
|
usage: /anticheat help
|
||||||
|
aliases: anti
|
||||||
Reference in new issue
Block a user