mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Fixed logging
This commit is contained in:
1 parent
98cf43a0fc
commit
4ef2534114
6 files changed
+13
-55
No files matched your search
@@ -23,6 +23,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
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 net.h31ix.anticheat.event.*;
|
import net.h31ix.anticheat.event.*;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||||
import net.h31ix.anticheat.manage.CheckType;
|
import net.h31ix.anticheat.manage.CheckType;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class PlayerListener extends EventListener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
|
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
|
||||||
{
|
{
|
||||||
|
log("wtf'ed", event.getPlayer(), CheckType.FLY);
|
||||||
if(!event.isFlying())
|
if(!event.isFlying())
|
||||||
{
|
{
|
||||||
backend.logEnterExit(event.getPlayer());
|
backend.logEnterExit(event.getPlayer());
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class AnticheatManager
|
|||||||
private UserManager userManager = null;
|
private UserManager userManager = null;
|
||||||
private CheckManager checkManager = null;
|
private CheckManager checkManager = null;
|
||||||
private Backend backend = null;
|
private Backend backend = null;
|
||||||
private Logger logger;
|
private final Logger fileLogger;
|
||||||
private Logger fileLogger;
|
|
||||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||||
private static Handler fileHandler;
|
private static Handler fileHandler;
|
||||||
private static final int LOG_LEVEL_HIGH = 3;
|
private static final int LOG_LEVEL_HIGH = 3;
|
||||||
@@ -55,8 +54,7 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
// now load all the others!!!!!
|
// now load all the others!!!!!
|
||||||
this.logger = logger;
|
fileLogger = Logger.getLogger("net.h31ix.anticheat.Anticheat");
|
||||||
this.fileLogger = Logger.getLogger("net.h31ix.anticheat.Anticheat");
|
|
||||||
configuration = new Configuration(this);
|
configuration = new Configuration(this);
|
||||||
xrayTracker = new XRayTracker();
|
xrayTracker = new XRayTracker();
|
||||||
userManager = new UserManager(configuration);
|
userManager = new UserManager(configuration);
|
||||||
@@ -84,7 +82,7 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
if (getConfiguration().logConsole())
|
if (getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
Bukkit.getConsoleSender().sendMessage(message);
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED+message);
|
||||||
}
|
}
|
||||||
if (getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
if (getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||||
{
|
{
|
||||||
@@ -95,15 +93,18 @@ public class AnticheatManager
|
|||||||
|
|
||||||
public void fileLog(String message)
|
public void fileLog(String message)
|
||||||
{
|
{
|
||||||
logger.info(message);
|
fileLogger.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getLastLogs()
|
public List<String> getLastLogs()
|
||||||
{
|
{
|
||||||
List<String> log = new CopyOnWriteArrayList<String>();
|
List<String> log = new CopyOnWriteArrayList<String>();
|
||||||
if (logs.size() < 30)
|
if (logs.size() < 30)
|
||||||
|
{
|
||||||
return logs;
|
return logs;
|
||||||
for(int i = 1; i < 31; i++) {
|
}
|
||||||
|
for(int i = 1; i < 31; i++)
|
||||||
|
{
|
||||||
log.add(logs.get(logs.size() - i));
|
log.add(logs.get(logs.size() - i));
|
||||||
}
|
}
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class User
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,21 +26,13 @@ import java.util.logging.LogRecord;
|
|||||||
|
|
||||||
public class FileFormatter extends Formatter
|
public class FileFormatter extends Formatter
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
||||||
private static final String lineSep = System.getProperty("line.separator");
|
private static final String lineSep = System.getProperty("line.separator");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record)
|
public String format(LogRecord record)
|
||||||
{
|
{
|
||||||
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();
|
||||||
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 "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
package net.h31ix.anticheat.util;
|
package net.h31ix.anticheat.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -33,7 +32,6 @@ public final class Utilities
|
|||||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||||
private static final List<Material> INTERACTABLE = new ArrayList<Material>();
|
private static final List<Material> INTERACTABLE = new ArrayList<Material>();
|
||||||
private static final HashSet<Byte> NOTSOLID = new HashSet<Byte>();
|
|
||||||
|
|
||||||
public static void alert(List<String> message)
|
public static void alert(List<String> message)
|
||||||
{
|
{
|
||||||
@@ -91,11 +89,6 @@ public final class Utilities
|
|||||||
return INTERACTABLE.contains(m);
|
return INTERACTABLE.contains(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<Byte> getNonSolid()
|
|
||||||
{
|
|
||||||
return NOTSOLID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean sprintFly(Player player)
|
public static boolean sprintFly(Player player)
|
||||||
{
|
{
|
||||||
return player.isSprinting() || player.isFlying();
|
return player.isSprinting() || player.isFlying();
|
||||||
@@ -168,36 +161,6 @@ public final class Utilities
|
|||||||
INTERACTABLE.add(Material.STONE_BUTTON);
|
INTERACTABLE.add(Material.STONE_BUTTON);
|
||||||
INTERACTABLE.add(Material.LEVER);
|
INTERACTABLE.add(Material.LEVER);
|
||||||
INTERACTABLE.add(Material.CHEST);
|
INTERACTABLE.add(Material.CHEST);
|
||||||
NOTSOLID.add((byte) Material.TORCH.getId());
|
|
||||||
NOTSOLID.add((byte) Material.REDSTONE_TORCH_OFF.getId());
|
|
||||||
NOTSOLID.add((byte) Material.REDSTONE_TORCH_OFF.getId());
|
|
||||||
NOTSOLID.add((byte) Material.FENCE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.FENCE_GATE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.IRON_FENCE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.NETHER_FENCE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.TRAP_DOOR.getId());
|
|
||||||
NOTSOLID.add((byte) Material.SIGN.getId());
|
|
||||||
NOTSOLID.add((byte) Material.STONE_BUTTON.getId());
|
|
||||||
NOTSOLID.add((byte) Material.LEVER.getId());
|
|
||||||
NOTSOLID.add((byte) Material.AIR.getId());
|
|
||||||
NOTSOLID.add((byte) Material.WATER.getId());
|
|
||||||
NOTSOLID.add((byte) Material.LAVA.getId());
|
|
||||||
NOTSOLID.add((byte) Material.REDSTONE_WIRE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.WOOD_PLATE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.STONE_PLATE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.SAPLING.getId());
|
|
||||||
NOTSOLID.add((byte) Material.RED_ROSE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.YELLOW_FLOWER.getId());
|
|
||||||
NOTSOLID.add((byte) Material.BROWN_MUSHROOM.getId());
|
|
||||||
NOTSOLID.add((byte) Material.RED_MUSHROOM.getId());
|
|
||||||
NOTSOLID.add((byte) Material.THIN_GLASS.getId());
|
|
||||||
NOTSOLID.add((byte) Material.LADDER.getId());
|
|
||||||
NOTSOLID.add((byte) Material.RAILS.getId());
|
|
||||||
NOTSOLID.add((byte) Material.DETECTOR_RAIL.getId());
|
|
||||||
NOTSOLID.add((byte) Material.POWERED_RAIL.getId());
|
|
||||||
NOTSOLID.add((byte) Material.STEP.getId());
|
|
||||||
NOTSOLID.add((byte) Material.VINE.getId());
|
|
||||||
NOTSOLID.add((byte) Material.ENCHANTMENT_TABLE.getId());
|
|
||||||
FOOD.add(Material.COOKED_BEEF);
|
FOOD.add(Material.COOKED_BEEF);
|
||||||
FOOD.add(Material.COOKED_CHICKEN);
|
FOOD.add(Material.COOKED_CHICKEN);
|
||||||
FOOD.add(Material.COOKED_FISH);
|
FOOD.add(Material.COOKED_FISH);
|
||||||
|
|||||||
Reference in new issue
Block a user