mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Improved logging, fixes issue #23
This commit is contained in:
1 parent
3a0b7369c9
commit
e3f92436ea
9 files changed
+71
-20
No files matched your search
@@ -23,6 +23,8 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -38,8 +40,7 @@ public class AnticheatManager
|
||||
private PlayerManager playerManager = null;
|
||||
private CheckManager checkManager = null;
|
||||
private Backend backend = null;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private static final Logger FILE_LOGGER = Logger.getLogger(AnticheatManager.class.getName());
|
||||
private Logger LOGGER, FILE_LOGGER;
|
||||
private static Handler handler;
|
||||
private static final int LOG_LEVEL_HIGH = 3;
|
||||
|
||||
@@ -47,6 +48,8 @@ public class AnticheatManager
|
||||
{
|
||||
plugin = instance;
|
||||
// now load all the others!!!!!
|
||||
LOGGER = plugin.getAnticheatLogger();
|
||||
FILE_LOGGER = LOGGER;
|
||||
configuration = new Configuration(this);
|
||||
xrayTracker = new XRayTracker();
|
||||
playerManager = new PlayerManager(this);
|
||||
@@ -60,21 +63,25 @@ public class AnticheatManager
|
||||
file.mkdir();
|
||||
}
|
||||
handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true);
|
||||
handler.setFormatter(new FileFormatter());
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
} catch (SecurityException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
handler.setFormatter(new SimpleFormatter());
|
||||
FILE_LOGGER.setUseParentHandlers(false);
|
||||
FILE_LOGGER.addHandler(handler);
|
||||
LOGGER.setUseParentHandlers(false);
|
||||
Handler chandler = new ConsoleHandler();
|
||||
chandler.setFormatter(new ConsoleFormatter());
|
||||
LOGGER.addHandler(chandler);
|
||||
}
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
if(getConfiguration().logConsole())
|
||||
{
|
||||
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||
LOGGER.warning(message);
|
||||
}
|
||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||
{
|
||||
@@ -84,7 +91,7 @@ public class AnticheatManager
|
||||
|
||||
public void fileLog(String message)
|
||||
{
|
||||
FILE_LOGGER.log(Level.WARNING, message);
|
||||
FILE_LOGGER.warning(message);
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* 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.manage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class Utilities
|
||||
{
|
||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||
|
||||
private Utilities()
|
||||
{
|
||||
|
||||
}
|
||||
public static void alert(String [] message)
|
||||
{
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.hasPermission("anticheat.mod") || p.isOp())
|
||||
{
|
||||
for(String msg : message)
|
||||
{
|
||||
p.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
Logger logger = Logger.getLogger("Minecraft");
|
||||
for(String msg : message)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||
}
|
||||
public static boolean cantStandClose(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||
}
|
||||
public static boolean cantStandFar(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
||||
}
|
||||
public static boolean canStand(Block block)
|
||||
{
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||
}
|
||||
public static boolean isInstantBreak(Material m)
|
||||
{
|
||||
return INSTANT_BREAK.contains(m);
|
||||
}
|
||||
public static boolean isFood(Material m)
|
||||
{
|
||||
return FOOD.contains(m);
|
||||
}
|
||||
public static boolean sprintFly(Player player)
|
||||
{
|
||||
return player.isSprinting() || player.isFlying();
|
||||
}
|
||||
public static boolean isOnLilyPad(Player player)
|
||||
{
|
||||
Block block = player.getLocation().getBlock();
|
||||
Material lily = Material.WATER_LILY;
|
||||
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
||||
}
|
||||
public static boolean isInt(String string)
|
||||
{
|
||||
boolean x = false;
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
x = true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
return x;
|
||||
}
|
||||
static
|
||||
{
|
||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||
INSTANT_BREAK.add(Material.RED_ROSE);
|
||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
|
||||
INSTANT_BREAK.add(Material.REDSTONE);
|
||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
|
||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
|
||||
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||
INSTANT_BREAK.add(Material.LONG_GRASS);
|
||||
INSTANT_BREAK.add(Material.PAINTING);
|
||||
INSTANT_BREAK.add(Material.WHEAT);
|
||||
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
|
||||
INSTANT_BREAK.add(Material.DIODE);
|
||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
|
||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
|
||||
INSTANT_BREAK.add(Material.SAPLING);
|
||||
INSTANT_BREAK.add(Material.TORCH);
|
||||
INSTANT_BREAK.add(Material.CROPS);
|
||||
INSTANT_BREAK.add(Material.SNOW);
|
||||
FOOD.add(Material.COOKED_BEEF);
|
||||
FOOD.add(Material.COOKED_CHICKEN);
|
||||
FOOD.add(Material.COOKED_FISH);
|
||||
FOOD.add(Material.GRILLED_PORK);
|
||||
FOOD.add(Material.PORK);
|
||||
FOOD.add(Material.MUSHROOM_SOUP);
|
||||
FOOD.add(Material.RAW_BEEF);
|
||||
FOOD.add(Material.RAW_CHICKEN);
|
||||
FOOD.add(Material.RAW_FISH);
|
||||
FOOD.add(Material.APPLE);
|
||||
FOOD.add(Material.GOLDEN_APPLE);
|
||||
FOOD.add(Material.MELON);
|
||||
FOOD.add(Material.COOKIE);
|
||||
FOOD.add(Material.BREAD);
|
||||
FOOD.add(Material.SPIDER_EYE);
|
||||
FOOD.add(Material.ROTTEN_FLESH);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user