Rename LogUtil to StaticLog.

This commit is contained in:
asofold 2014-11-17 11:25:51 +01:00
parent 1a88df80c5
commit 37c1da73ff
41 changed files with 182 additions and 184 deletions

View File

@ -1,4 +1,4 @@
package fr.neatmonster.nocheatplus.utilities.ds;
package fr.neatmonster.nocheatplus.utilities.ds.corw;
import java.util.Collection;
import java.util.Collections;

View File

@ -16,7 +16,7 @@ import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.stats.Counters;
import fr.neatmonster.nocheatplus.utilities.TickTask;
@ -44,7 +44,7 @@ public class FastConsume extends Check implements Listener{
super(CheckType.INVENTORY_FASTCONSUME);
// Overrides the instant-eat check.
ConfigManager.setForAllConfigs(ConfPaths.INVENTORY_INSTANTEAT_CHECK, false);
LogUtil.logInfo("[NoCheatPlus] Inventory checks: FastConsume is available, disabled InstantEat.");
StaticLog.logInfo("[NoCheatPlus] Inventory checks: FastConsume is available, disabled InstantEat.");
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)

View File

@ -16,7 +16,7 @@ import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.stats.Counters;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.ds.LinkedHashMapCOW;
import fr.neatmonster.nocheatplus.utilities.ds.corw.LinkedHashMapCOW;
/**
* Prevent extremely fast ticking by just sending packets that don't do anything

View File

@ -17,7 +17,7 @@ import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/**
@ -30,7 +30,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload{
private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
public ProtocolLibComponent(Plugin plugin) {
LogUtil.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
register(plugin);
}
@ -47,7 +47,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload{
for (PacketAdapter adapter : registeredPacketAdapters) {
names.add(adapter.getClass().getSimpleName());
}
LogUtil.logInfo("[NoCheatPlus] Available (and activated) packet level hooks: " + StringUtil.join(names, " | "));
StaticLog.logInfo("[NoCheatPlus] Available (and activated) packet level hooks: " + StringUtil.join(names, " | "));
}
}
@ -58,8 +58,8 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload{
ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
registeredPacketAdapters.add(adapter);
} catch (Throwable t) {
LogUtil.logWarning("[NoCheatPlus] Could not register packet level hook: " + clazz.getSimpleName());
LogUtil.logWarning(t);
StaticLog.logWarning("[NoCheatPlus] Could not register packet level hook: " + clazz.getSimpleName());
StaticLog.logWarning(t);
}
}
@ -82,7 +82,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload{
protocolManager.removePacketListener(adapter);
api.removeComponent(adapter); // Bit heavy, but consistent.
} catch (Throwable t) {
LogUtil.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName());
StaticLog.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName());
}
}
registeredPacketAdapters.clear();

View File

@ -8,7 +8,7 @@ import java.util.Map;
import fr.neatmonster.nocheatplus.actions.AbstractActionList.ActionListFactory;
import fr.neatmonster.nocheatplus.actions.types.CommandAction;
import fr.neatmonster.nocheatplus.actions.types.DummyAction;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
public abstract class AbstractActionFactory <D extends ActionData, L extends AbstractActionList<D, L>>{
@ -70,7 +70,7 @@ public abstract class AbstractActionFactory <D extends ActionData, L extends Abs
}
list.setActions(vl, createActions(def.split("\\s+")));
} catch (final Exception e) {
LogUtil.logWarning("[NoCheatPlus] Couldn't parse action definition 'vl:" + s + "'.");
StaticLog.logWarning("[NoCheatPlus] Couldn't parse action definition 'vl:" + s + "'.");
}
}
@ -94,7 +94,7 @@ public abstract class AbstractActionFactory <D extends ActionData, L extends Abs
try {
actions.add(createAction(def));
} catch (final IllegalArgumentException e) {
LogUtil.logWarning("[NoCheatPlus] Failed to create action: " + e.getMessage());
StaticLog.logWarning("[NoCheatPlus] Failed to create action: " + e.getMessage());
actions.add(new DummyAction<D, L>(def));
}
}
@ -125,7 +125,7 @@ public abstract class AbstractActionFactory <D extends ActionData, L extends Abs
delay = Integer.parseInt(parts[1]);
repeat = Integer.parseInt(parts[2]);
} catch (final Exception e) {
LogUtil.logWarning("[NoCheatPlus] Couldn't parse details of command '" + definition
StaticLog.logWarning("[NoCheatPlus] Couldn't parse details of command '" + definition
+ "', will use default values instead.");
delay = 0;
repeat = 0;

View File

@ -5,7 +5,7 @@ import java.util.Map;
import fr.neatmonster.nocheatplus.actions.types.CancelAction;
import fr.neatmonster.nocheatplus.actions.types.LogAction;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Helps with creating Actions out of text string definitions.
@ -76,9 +76,9 @@ public class ActionFactory extends AbstractActionFactory<ViolationData, ActionLi
toChat = parts[3].contains("i");
toFile = parts[3].contains("f");
} catch (final Exception e) {
LogUtil.logWarning("[NoCheatPlus] Couldn't parse details of log action '" + definition
StaticLog.logWarning("[NoCheatPlus] Couldn't parse details of log action '" + definition
+ "', will use default values instead.");
LogUtil.logWarning(e);
StaticLog.logWarning(e);
delay = 0;
repeat = 1;
toConsole = true;

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandException;
import fr.neatmonster.nocheatplus.actions.AbstractActionList;
import fr.neatmonster.nocheatplus.actions.ParameterHolder;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Execute a command by imitating an administrator typing the command directly into the console.
@ -38,7 +38,7 @@ public class CommandAction<D extends ParameterHolder, L extends AbstractActionLi
try {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} catch (final CommandException e) {
LogUtil.logWarning("[NoCheatPlus] Failed to execute the command '" + command + "': " + e.getMessage()
StaticLog.logWarning("[NoCheatPlus] Failed to execute the command '" + command + "': " + e.getMessage()
+ ", please check if everything is setup correct.");
} catch (final Exception e) {
// I don't care in this case, your problem if your command fails.

View File

@ -8,7 +8,7 @@ import fr.neatmonster.nocheatplus.actions.ActionList;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFileWithActions;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.logging.StaticLogFile;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
@ -103,7 +103,7 @@ public class LogAction extends ActionWithParameters<ViolationData, ActionList> {
NCPAPIProvider.getNoCheatPlusAPI().sendAdminNotifyMessage(ColorUtil.replaceColors(prefixChat + message));
}
if (toConsole) {
LogUtil.logInfo(ColorUtil.removeColors(prefixConsole + message));
StaticLog.logInfo(ColorUtil.removeColors(prefixConsole + message));
}
if (toFile) {
StaticLogFile.fileLogger.info(ColorUtil.removeColors(prefixFile + message));

View File

@ -11,7 +11,7 @@ import fr.neatmonster.nocheatplus.actions.ActionList;
import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.actions.types.CancelAction;
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Violation specific data, for executing actions.<br>
@ -109,7 +109,7 @@ public class ViolationData implements IViolationInfo, ActionData{
}
return cancel;
} catch (final Exception e) {
LogUtil.logSevere(e);
StaticLog.logSevere(e);
// On exceptions cancel events.
return true;
}

View File

@ -18,7 +18,7 @@ import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
@ -307,7 +307,7 @@ public class Text extends Check implements INotifyReload {
debugParts.add("Normal: min=" + StringUtil.fdec3.format(cc.textFreqNormMin) +", weight=" + StringUtil.fdec3.format(cc.textFreqNormWeight) + " => accumulated=" + StringUtil.fdec3.format(accumulated));
debugParts.add("Short-term: min=" + StringUtil.fdec3.format(cc.textFreqShortTermMin) +", weight=" + StringUtil.fdec3.format(cc.textFreqShortTermWeight) + " => accumulated=" + StringUtil.fdec3.format(shortTermAccumulated));
debugParts.add("vl: " + StringUtil.fdec3.format(data.textVL));
LogUtil.scheduleLogInfo(debugParts, " | ");
StaticLog.scheduleLogInfo(debugParts, " | ");
debugParts.clear();
}

View File

@ -24,7 +24,7 @@ import fr.neatmonster.nocheatplus.components.IHaveCheckType;
import fr.neatmonster.nocheatplus.components.IRemoveData;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
@ -78,8 +78,8 @@ public class LetterEngine implements IRemoveData, IHaveCheckType, ConsistencyChe
result.put(processor.getProcessorName(), processor.process(letterCount) * cc.textGlobalWeight);
}
catch( final Exception e){
LogUtil.logSevere("[NoCheatPlus] chat.text: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] chat.text: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
StaticLog.logSevere(e);
continue;
}
}
@ -93,8 +93,8 @@ public class LetterEngine implements IRemoveData, IHaveCheckType, ConsistencyChe
result.put(processor.getProcessorName(), processor.process(letterCount) * cc.textPlayerWeight);
}
catch( final Exception e){
LogUtil.logSevere("[NoCheatPlus] chat.text: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] chat.text: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
StaticLog.logSevere(e);
continue;
}
}

View File

@ -18,7 +18,7 @@ import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
@ -102,7 +102,7 @@ public class CombinedConfig extends ACheckConfig {
}
catch (final Exception e){
error = true;
LogUtil.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input);
StaticLog.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.ignore): " + input);
}
}
// Read modifiers for causes.
@ -120,11 +120,11 @@ public class CombinedConfig extends ACheckConfig {
}
catch (final Exception e){
error = true;
LogUtil.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.modifiers): " + input);
StaticLog.logWarning("[NoCheatPlus] Bad damage cause (combined.invulnerable.modifiers): " + input);
}
}
invulnerableModifierDefault = defaultMod;
if (error) LogUtil.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", "));
if (error) StaticLog.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", "));
invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS);
invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE);

View File

@ -62,7 +62,7 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.logging.DebugUtil;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.stats.Counters;
@ -132,9 +132,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// TODO: reset the bounding box of the player ?
if (MovingConfig.getConfig(player).tempKickIllegal) {
NCPAPIProvider.getNoCheatPlusAPI().denyLogin(player.getName(), 24L * 60L * 60L * 1000L);
LogUtil.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them and deny login for 24 hours");
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them and deny login for 24 hours");
} else {
LogUtil.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them.");
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them.");
}
CheckUtils.kickIllegalMove(player);
}
@ -747,7 +747,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
*/
private void onVehicleLeaveMiss(final Player player, final MovingData data, final MovingConfig cc) {
if (cc.debug) {
LogUtil.logWarning("[NoCheatPlus] VehicleExitEvent missing for: " + player.getName());
StaticLog.logWarning("[NoCheatPlus] VehicleExitEvent missing for: " + player.getName());
}
onPlayerVehicleLeave(player, null);
// if (BlockProperties.isRails(pFrom.getTypeId())) {
@ -1287,7 +1287,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final int loaded = BlockCache.ensureChunksLoaded(loc.getWorld(), loc.getX(), loc.getZ(), 3.0);
if (loaded > 0 && cc.debug && BuildParameters.debugLevel > 0) {
// DEBUG
LogUtil.logInfo("[NoCheatPlus] Player join: Loaded " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " for player: " + player.getName());
StaticLog.logInfo("[NoCheatPlus] Player join: Loaded " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " for player: " + player.getName());
}
}
@ -1358,7 +1358,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final Location loc = player.getLocation(useLoc);
// Debug logout.
if (cc.debug) {
LogUtil.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString());
StaticLog.logInfo("[NoCheatPlus] Player " + player.getName() + " leaves at location: " + loc.toString());
}
if (!player.isSleeping() && !player.isDead()) {
// Check for missed moves.
@ -1371,15 +1371,15 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// TODO: Consider to always set back here. Might skip on big distances.
if (TrigUtil.manhattan(loc, refLoc) > 0 || BlockProperties.isPassable(refLoc)) {
if (passable.isEnabled(player)) {
LogUtil.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " leaves, having moved into a block (not tracked by moving checks): " + player.getWorld().getName() + " / " + DebugUtil.formatMove(refLoc, loc));
StaticLog.logWarning("[NoCheatPlus] Potential exploit: Player " + player.getName() + " leaves, having moved into a block (not tracked by moving checks): " + player.getWorld().getName() + " / " + DebugUtil.formatMove(refLoc, loc));
// TODO: Actually trigger a passable violation (+tag).
if (d > 1.25) {
LogUtil.logWarning("[NoCheatPlus] SKIP set-back for " + player.getName() + ", because distance is too high (risk of false positives): " + d);
StaticLog.logWarning("[NoCheatPlus] SKIP set-back for " + player.getName() + ", because distance is too high (risk of false positives): " + d);
} else {
LogUtil.logInfo("[NoCheatPlus] Set back player " + player.getName() + ": " + DebugUtil.formatLocation(refLoc));
StaticLog.logInfo("[NoCheatPlus] Set back player " + player.getName() + ": " + DebugUtil.formatLocation(refLoc));
data.prepareSetBack(refLoc);
if (!player.teleport(refLoc)) {
LogUtil.logWarning("[NoCheatPlus] FAILED to set back player " + player.getName());
StaticLog.logWarning("[NoCheatPlus] FAILED to set back player " + player.getName());
}
}
}
@ -1643,7 +1643,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final int loaded = info.from.ensureChunksLoaded();
if (loaded > 0 && cc.debug && BuildParameters.debugLevel > 0) {
// DEBUG
LogUtil.logInfo("[NoCheatPlus] Hover check: Needed to load " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " around " + loc.getBlockX() + "," + loc.getBlockZ() + " in order to check player: " + player.getName());
StaticLog.logInfo("[NoCheatPlus] Hover check: Needed to load " + loaded + " chunk" + (loaded == 1 ? "" : "s") + " for the world " + loc.getWorld().getName() + " around " + loc.getBlockX() + "," + loc.getBlockZ() + " in order to check player: " + player.getName());
}
if (info.from.isOnGround() || info.from.isResetCond() || info.from.isAboveLadder() || info.from.isAboveStairs()) {
res = true;

View File

@ -4,7 +4,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.TeleportUtil;
/**
@ -34,7 +34,7 @@ public class VehicleSetBack implements Runnable{
TeleportUtil.teleport(vehicle, player, location, debug);
}
catch(Throwable t){
LogUtil.logSevere(t);
StaticLog.logSevere(t);
}
}

View File

@ -17,7 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
public class CommandUtil {
@ -30,7 +30,7 @@ public class CommandUtil {
return NCPAPIProvider.getNoCheatPlusAPI().getMCAccess().getCommandMap();
}
catch (Throwable t) {
LogUtil.logSevere(t);
StaticLog.logSevere(t);
return null;
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.AbstractCommand;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.utilities.IdUtil;
@ -59,9 +59,9 @@ public class BanCommand extends BaseCommand {
if (player == null && !IdUtil.isValidMinecraftUserName(name)) {
UUID id = IdUtil.UUIDFromStringSafe(name);
if (id != null) {
LogUtil.logWarning("Banning by UUID might not work (" + id.toString()+"), relay to the vanilla command.");
StaticLog.logWarning("Banning by UUID might not work (" + id.toString()+"), relay to the vanilla command.");
} else {
LogUtil.logWarning("Might not be a valid user name: " + name);
StaticLog.logWarning("Might not be a valid user name: " + name);
}
}
if (player != null){
@ -74,7 +74,7 @@ public class BanCommand extends BaseCommand {
}
private void logBan(CommandSender sender, Player player, String name, String reason) {
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Banned " + name + (player != null ? ("/" + player.getName()) : "") + " : " + reason);
StaticLog.logInfo("[NoCheatPlus] (" + sender.getName() + ") Banned " + name + (player != null ? ("/" + player.getName()) : "") + " : " + reason);
}
/* (non-Javadoc)

View File

@ -10,7 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.command.AbstractCommand;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
@ -48,7 +48,7 @@ public class DenyLoginCommand extends BaseCommand {
NCPAPIProvider.getNoCheatPlusAPI().denyLogin(name, duration);
if (player == null) return;
player.kickPlayer(reason);
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
StaticLog.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
}
/* (non-Javadoc)

View File

@ -9,7 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.AbstractCommand;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
@ -38,7 +38,7 @@ public class KickCommand extends BaseCommand {
Player player = DataManager.getPlayer(name);
if (player == null) return;
player.kickPlayer(reason);
LogUtil.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
StaticLog.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
}
/* (non-Javadoc)

View File

@ -11,7 +11,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
/**
@ -213,7 +213,7 @@ public class BridgeHealth {
private static void checkLogEntry(final String tag) {
// New entry.
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_DEBUG)){
LogUtil.logWarning("[NoCheatPlus] API incompatibility detected: " + tag);
StaticLog.logWarning("[NoCheatPlus] API incompatibility detected: " + tag);
}
}

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.BlockFlags;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
@ -87,7 +87,7 @@ public class BlocksMC1_5 implements BlockPropertiesSetup {
// 95 Locked chest
BlockProperties.setBlockProps(95, BlockProperties.instantType);
LogUtil.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.5 blocks.");
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.5 blocks.");
}
}

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.BlockFlags;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.BlockProperties.BlockProps;
@ -38,7 +38,7 @@ public class BlocksMC1_6_1 implements BlockPropertiesSetup{
BlockProperties.setBlockProps(171, new BlockProps(BlockProperties.noTool, 0.1f, BlockProperties.secToMs(0.15)));
BlockProperties.setBlockFlags(171, BlockProperties.F_GROUND|BlockProperties.F_IGN_PASSABLE|BlockProperties.F_GROUND_HEIGHT);
LogUtil.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.6.1 blocks.");
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.6.1 blocks.");
}
}

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
public class BlocksMC1_7_2 implements BlockPropertiesSetup{
@ -34,7 +34,7 @@ public class BlocksMC1_7_2 implements BlockPropertiesSetup{
// Large flowers
BlockInit.setAs(175, Material.YELLOW_FLOWER);
LogUtil.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.7.2 blocks.");
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.7.2 blocks.");
}
}

View File

@ -5,7 +5,7 @@ import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.BlockFlags;
public class BlocksMC1_8 implements BlockPropertiesSetup {
@ -102,7 +102,7 @@ public class BlocksMC1_8 implements BlockPropertiesSetup {
// 197(DARK_OAK_DOOR
BlockInit.setAs(197, Material.WOODEN_DOOR);
LogUtil.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.8 blocks.");
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.8 blocks.");
}
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
public class VanillaBlocksFactory implements BlockPropertiesSetup{
@ -26,8 +26,8 @@ public class VanillaBlocksFactory implements BlockPropertiesSetup{
setup.setupBlockProperties(worldConfigProvider);
}
catch(Throwable t){
LogUtil.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t);
// Abort further processing.
break;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.plugin.Plugin;
import fr.neatmonster.nocheatplus.actions.ActionFactory;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Central location for everything that's described in the configuration file(s).<br>
@ -204,12 +204,12 @@ public class ConfigManager {
globalConfig.save(globalFile);
}
} catch (final Exception e) {
LogUtil.logSevere("[NoCheatPlus] Could not save back config.yml (see exception below).");
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] Could not save back config.yml (see exception below).");
StaticLog.logSevere(e);
}
} catch (final Exception e) {
LogUtil.logSevere("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
StaticLog.logSevere(e);
}
}
else {
@ -220,7 +220,7 @@ public class ConfigManager {
globalConfig.set(ConfPaths.CONFIGVERSION_SAVED, DefaultConfig.buildNumber);
globalConfig.save(globalFile);
} catch (final Exception e) {
LogUtil.logSevere(e);
StaticLog.logSevere(e);
}
}
// globalConfig.setActionFactory();
@ -254,12 +254,12 @@ public class ConfigManager {
try{
if (worldConfig.getBoolean(ConfPaths.SAVEBACKCONFIG)) worldConfig.save(worldFile);
} catch (final Exception e){
LogUtil.logSevere("[NoCheatPlus] Couldn't save back world-specific configuration for " + worldEntry.getKey() + " (see exception below).");
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] Couldn't save back world-specific configuration for " + worldEntry.getKey() + " (see exception below).");
StaticLog.logSevere(e);
}
} catch (final Exception e) {
LogUtil.logSevere("[NoCheatPlus] Couldn't load world-specific configuration for " + worldEntry.getKey() + " (see exception below). Continue with global default settings...");
LogUtil.logSevere(e);
StaticLog.logSevere("[NoCheatPlus] Couldn't load world-specific configuration for " + worldEntry.getKey() + " (see exception below). Continue with global default settings...");
StaticLog.logSevere(e);
}
worldConfig.setDefaults(globalConfig);
worldConfig.options().copyDefaults(true);

View File

@ -19,7 +19,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.MemoryConfiguration;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.ds.prefixtree.CharPrefixTree;
import fr.neatmonster.nocheatplus.utilities.ds.prefixtree.SimpleCharPrefixTree;
@ -151,8 +151,8 @@ public class PathUtils {
}
catch(Throwable t){
// Do log this one.
LogUtil.logSevere("[NoCheatPlus] Failed to save configuration (" + configName + ") with changes: " + t.getClass().getSimpleName());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] Failed to save configuration (" + configName + ") with changes: " + t.getClass().getSimpleName());
StaticLog.logSevere(t);
}
}
} catch (FileNotFoundException e) {

View File

@ -8,7 +8,7 @@ import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.yaml.snakeyaml.DumperOptions;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
public class RawConfigFile extends YamlConfiguration{
@ -157,7 +157,7 @@ public class RawConfigFile extends YamlConfiguration{
for (final String entry : content){
final Integer id = parseTypeId(entry);
if (id == null){
LogUtil.logWarning("[NoCheatPlus] Bad material entry (" + path +"): " + entry);
StaticLog.logWarning("[NoCheatPlus] Bad material entry (" + path +"): " + entry);
}
else{
target.add(id);
@ -176,7 +176,7 @@ public class RawConfigFile extends YamlConfiguration{
for (final String entry : content){
final Material mat = parseMaterial(entry);
if (mat == null){
LogUtil.logWarning("[NoCheatPlus] Bad material entry (" + path +"): " + entry);
StaticLog.logWarning("[NoCheatPlus] Bad material entry (" + path +"): " + entry);
}
else{
target.add(mat);

View File

@ -14,7 +14,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* listener registered for one event only. Allows to delegate to other registered listeners.
@ -116,11 +116,11 @@ public class GenericListener<E extends Event> implements Listener, EventExecutor
try{
final EventException e = new EventException(t, descr);
// TODO: log it / more details!
if (event.isAsynchronous()) LogUtil.scheduleLogSevere(e);
else LogUtil.logSevere(e);
if (event.isAsynchronous()) StaticLog.scheduleLogSevere(e);
else StaticLog.logSevere(e);
}
catch (Throwable t2){
LogUtil.scheduleLogSevere("Could not log exception: " + descr);
StaticLog.scheduleLogSevere("Could not log exception: " + descr);
}
}

View File

@ -16,7 +16,7 @@ import org.bukkit.plugin.Plugin;
import fr.neatmonster.nocheatplus.components.ComponentWithName;
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry;
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry.MethodOrder;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* This class allows to register event-listeners which will all be called form within one event handler per event+priority combination.<br>
@ -144,17 +144,17 @@ public class ListenerManager {
try{
method.setAccessible(true);
} catch (SecurityException e){
LogUtil.logWarning("[ListenerManager] Can not set method accessible: " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
StaticLog.logWarning("[ListenerManager] Can not set method accessible: " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
}
}
Class<?>[] argTypes = method.getParameterTypes();
if (argTypes.length != 1){
LogUtil.logWarning("[ListenerManager] Bad method signature (number of arguments not 1): " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
StaticLog.logWarning("[ListenerManager] Bad method signature (number of arguments not 1): " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
continue;
}
Class<?> eventType = argTypes[0];
if (!Event.class.isAssignableFrom(eventType)){
LogUtil.logWarning("[ListenerManager] Bad method signature (argument does not extend Event): " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
StaticLog.logWarning("[ListenerManager] Bad method signature (argument does not extend Event): " + method.toGenericString() +" registered in " + clazz.getName()+ ", ignoring it!");
continue;
}
Class<? extends Event> checkedEventType = eventType.asSubclass(Event.class);

View File

@ -18,7 +18,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.components.NCPListener;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/**
@ -307,7 +307,7 @@ public class NCPExemptionManager {
if (wrong != 0){
details.add("wrong entity-ids (" + wrong + ")");
}
LogUtil.logWarning("[NoCheatPlus] ExemptionManager inconsistencies: " + StringUtil.join(details, " | "));
StaticLog.logWarning("[NoCheatPlus] ExemptionManager inconsistencies: " + StringUtil.join(details, " | "));
}
}

View File

@ -1,7 +1,5 @@
package fr.neatmonster.nocheatplus.logging;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
@ -11,11 +9,11 @@ import org.bukkit.Bukkit;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/**
* Static access methods for logging access (mostly uses the Bukkit logger).
* Static access methods for more or less direct logging using either Bukkit.getLogger() or System.out.
* @author mc_dev
*
*/
public class LogUtil {
public class StaticLog {
private static boolean useBukkitLogger = true;
@ -27,6 +25,7 @@ public class LogUtil {
useBukkitLogger = use;
}
// TODO: Remove toString method !
public static String toString(final Throwable t){
return StringUtil.throwableToString(t);
}
@ -119,7 +118,7 @@ public class LogUtil {
return Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("NoCheatPlus"), new Runnable() {
@Override
public final void run() {
Bukkit.getLogger().log(level, message);
StaticLog.log(level, message);
}
}) != -1;
} catch (final Exception exc) {

View File

@ -1,8 +1,6 @@
package fr.neatmonster.nocheatplus.logging;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
@ -97,14 +95,14 @@ public class StaticLogFile {
try {
logFile.getParentFile().mkdirs();
} catch (final Exception e) {
LogUtil.logSevere(e);
StaticLog.logSevere(e);
}
fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
fileHandler.setLevel(Level.ALL);
fileHandler.setFormatter(StaticLogFile.LogFileFormatter.newInstance());
logger.addHandler(fileHandler);
} catch (final Exception e) {
LogUtil.logSevere(e);
StaticLog.logSevere(e);
}
fileLogger = logger;
}

View File

@ -46,7 +46,7 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.hooks.APIUtils;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/**
@ -457,7 +457,7 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
onlinePlayers.clear();
// Finally alert (summary) if inconsistencies found.
if (foundInconsistencies > 0) {
LogUtil.logWarning("[NoCheatPlus] DataMan found " + foundInconsistencies + " inconsistencies (warnings suppressed).");
StaticLog.logWarning("[NoCheatPlus] DataMan found " + foundInconsistencies + " inconsistencies (warnings suppressed).");
foundInconsistencies = 0;
}
}
@ -508,7 +508,7 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
details.add("changed player instances (" + changed + ")");
}
LogUtil.logWarning("[NoCheatPlus] DataMan inconsistencies: " + StringUtil.join(details, " | "));
StaticLog.logWarning("[NoCheatPlus] DataMan inconsistencies: " + StringUtil.join(details, " | "));
}
}
}

View File

@ -7,7 +7,7 @@ import java.util.Map;
import org.bukkit.ChatColor;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* A not too fat timings class re-used from other plugins.
@ -83,7 +83,7 @@ public final class Timings {
if ( ts > tsStats+periodStats){
tsStats = ts;
// print out stats !
LogUtil.logInfo(getStatsStr());
StaticLog.logInfo(getStatsStr());
}
}
}

View File

@ -26,7 +26,7 @@ import fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.VanillaBlocksFactor
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.RawConfigFile;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Properties of blocks.
@ -417,8 +417,8 @@ public class BlockProperties {
new VanillaBlocksFactory().setupBlockProperties(worldConfigProvider);
}
catch(Throwable t) {
LogUtil.logSevere("[NoCheatPlus] Could not initialize vanilla blocks: " + t.getClass().getSimpleName() + " - " + t.getMessage());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] Could not initialize vanilla blocks: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t);
}
// Allow mcAccess to setup block properties.
if (mcAccess instanceof BlockPropertiesSetup) {
@ -426,14 +426,14 @@ public class BlockProperties {
((BlockPropertiesSetup) mcAccess).setupBlockProperties(worldConfigProvider);
}
catch(Throwable t) {
LogUtil.logSevere("[NoCheatPlus] McAccess.setupBlockProperties (" + mcAccess.getClass().getSimpleName() + ") could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] McAccess.setupBlockProperties (" + mcAccess.getClass().getSimpleName() + ") could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t);
}
}
// TODO: Add registry for further BlockPropertiesSetup instances.
}
catch(Throwable t) {
LogUtil.logSevere(t);
StaticLog.logSevere(t);
}
}
@ -777,8 +777,8 @@ public class BlockProperties {
public static void dumpBlocks(boolean all) {
List<String> missing = new LinkedList<String>();
if (all) {
LogUtil.logInfo("[NoCheatPlus] Dump block properties for fastbreak check:");
LogUtil.logInfo("--- Present entries -------------------------------");
StaticLog.logInfo("[NoCheatPlus] Dump block properties for fastbreak check:");
StaticLog.logInfo("--- Present entries -------------------------------");
}
List<String> tags = new ArrayList<String>();
for (int i = 0; i < blocks.length; i++) {
@ -804,15 +804,15 @@ public class BlockProperties {
}
else {
if (all) {
LogUtil.logInfo(i + ": (" + mat + tagsJoined + ") " + blocks[i].toString());
StaticLog.logInfo(i + ": (" + mat + tagsJoined + ") " + blocks[i].toString());
}
}
}
if (!missing.isEmpty()) {
Bukkit.getLogger().warning("[NoCheatPlus] The block breaking data is incomplete, default to allow instant breaking:");
LogUtil.logWarning("--- Missing entries -------------------------------");
StaticLog.logWarning("--- Missing entries -------------------------------");
for (String spec : missing) {
LogUtil.logWarning(spec);
StaticLog.logWarning(spec);
}
}
}
@ -1906,7 +1906,7 @@ public class BlockProperties {
for (final String input : config.getStringList(pathPrefix + ConfPaths.SUB_IGNOREPASSABLE)) {
final Integer id = RawConfigFile.parseTypeId(input);
if (id == null || id < 0 || id >= 4096) {
LogUtil.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_IGNOREPASSABLE + "): " + input);
StaticLog.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_IGNOREPASSABLE + "): " + input);
}
else {
blockFlags[id] |= F_IGN_PASSABLE;
@ -1917,7 +1917,7 @@ public class BlockProperties {
for (final String input : config.getStringList(pathPrefix + ConfPaths.SUB_ALLOWINSTANTBREAK)) {
final Integer id = RawConfigFile.parseTypeId(input);
if (id == null || id < 0 || id >= 4096) {
LogUtil.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_ALLOWINSTANTBREAK + "): " + input);
StaticLog.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_ALLOWINSTANTBREAK + "): " + input);
}
else {
setBlockProps(id, instantType);
@ -1933,12 +1933,12 @@ public class BlockProperties {
final String key = entry.getKey();
final Integer id = RawConfigFile.parseTypeId(key);
if (id == null || id < 0 || id >= 4096) {
LogUtil.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + "): " + key);
StaticLog.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + "): " + key);
continue;
}
final Object obj = entry.getValue();
if (!(obj instanceof String)) {
LogUtil.logWarning("[NoCheatplus] Bad flags at " + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + " for key: " + key);
StaticLog.logWarning("[NoCheatplus] Bad flags at " + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + " for key: " + key);
hasErrors = true;
continue;
}
@ -1957,7 +1957,7 @@ public class BlockProperties {
try{
flags |= parseFlag(input);
} catch(InputMismatchException e) {
LogUtil.logWarning("[NoCheatplus] Bad flag at " + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + " for key " + key + " (skip setting flags for this block): " + input);
StaticLog.logWarning("[NoCheatplus] Bad flag at " + pathPrefix + ConfPaths.SUB_OVERRIDEFLAGS + " for key " + key + " (skip setting flags for this block): " + input);
error = true;
hasErrors = true;
break;
@ -1969,7 +1969,7 @@ public class BlockProperties {
blockFlags[id] = flags;
}
if (hasErrors) {
LogUtil.logInfo("[NoCheatPlus] Overriding block-flags was not entirely successful, all available flags: \n" + StringUtil.join(flagNameMap.values(), "|"));
StaticLog.logInfo("[NoCheatPlus] Overriding block-flags was not entirely successful, all available flags: \n" + StringUtil.join(flagNameMap.values(), "|"));
}
}
}

View File

@ -7,7 +7,7 @@ import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakData;
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
import fr.neatmonster.nocheatplus.checks.fight.FightData;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryData;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Random auxiliary gear, some might have general quality. Contents are likely to get moved to other classes.
@ -20,7 +20,7 @@ public class CheckUtils {
*/
public static void kickIllegalMove(final Player player){
player.kickPlayer("Illegal move.");
LogUtil.logWarning("[NCP] Disconnect " + player.getName() + " due to illegal move!");
StaticLog.logWarning("[NCP] Disconnect " + player.getName() + " due to illegal move!");
}
/**

View File

@ -14,7 +14,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.components.TickListener;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.players.DataManager;
/**
@ -237,8 +237,8 @@ public class TickTask implements Runnable {
}
catch(Throwable t) {
// Unlikely.
LogUtil.logWarning("[NoCheatPlus] Failed to set OnDemandTickListener to unregistered state: " + t.getClass().getSimpleName());
LogUtil.logWarning(t);
StaticLog.logWarning("[NoCheatPlus] Failed to set OnDemandTickListener to unregistered state: " + t.getClass().getSimpleName());
StaticLog.logWarning(t);
}
}
}
@ -417,6 +417,7 @@ public class TickTask implements Runnable {
* @param locked
*/
public static void setLocked(boolean locked) {
// TODO: synchronize over lists !?
TickTask.locked = locked;
}
@ -475,8 +476,8 @@ public class TickTask implements Runnable {
listener.onTick(tick, timeLast);
}
catch(Throwable t) {
LogUtil.logSevere("[NoCheatPlus] (TickTask) TickListener generated an exception:");
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] (TickTask) TickListener generated an exception:");
StaticLog.logSevere(t);
}
}
}
@ -496,7 +497,7 @@ public class TickTask implements Runnable {
// Time running backwards check (not only players can!).
if (timeLast > time) {
LogUtil.logWarning("[NoCheatPlus] System time ran backwards (" + timeLast + "->" + time + "), clear all data and history...");
StaticLog.logWarning("[NoCheatPlus] System time ran backwards (" + timeLast + "->" + time + "), clear all data and history...");
DataManager.clearData(CheckType.ALL);
lastDur = 50;
for (int i = 0; i < spikeDurations.length; i++) {

View File

@ -69,7 +69,7 @@ import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.event.IHaveMethodOrder;
import fr.neatmonster.nocheatplus.event.ListenerManager;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.logging.StaticLogFile;
import fr.neatmonster.nocheatplus.permissions.PermissionUtil;
import fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEntry;
@ -469,7 +469,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
if (listener instanceof IHaveMethodOrder){
// TODO: Might log the order too, might prevent registration ?
// TODO: Alternative: queue listeners and register after startup (!)
LogUtil.logWarning("[NoCheatPlus] Listener demands registration order, but listeners are not managed: " + listener.getClass().getName());
StaticLog.logWarning("[NoCheatPlus] Listener demands registration order, but listeners are not managed: " + listener.getClass().getName());
}
}
}
@ -530,10 +530,10 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Remove listener references.
if (verbose){
if (listenerManager.hasListenerMethods()) {
LogUtil.logInfo("[NoCheatPlus] Cleanup ListenerManager...");
StaticLog.logInfo("[NoCheatPlus] Cleanup ListenerManager...");
}
else {
LogUtil.logInfo("[NoCheatPlus] (ListenerManager not in use, prevent registering...)");
StaticLog.logInfo("[NoCheatPlus] (ListenerManager not in use, prevent registering...)");
}
}
listenerManager.setRegisterDirectly(false);
@ -549,7 +549,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Stop the tickTask.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Stop TickTask...");
StaticLog.logInfo("[NoCheatPlus] Stop TickTask...");
}
TickTask.setLocked(true);
TickTask.purge();
@ -565,34 +565,34 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Just to be sure nothing gets left out.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
StaticLog.logInfo("[NoCheatPlus] Stop all remaining tasks...");
}
sched.cancelTasks(this);
// Exemptions cleanup.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Reset ExemptionManager...");
StaticLog.logInfo("[NoCheatPlus] Reset ExemptionManager...");
}
NCPExemptionManager.clear();
// Data cleanup.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] onDisable calls (include DataManager cleanup)...");
StaticLog.logInfo("[NoCheatPlus] onDisable calls (include DataManager cleanup)...");
}
for (final DisableListener dl : disableListeners) {
try {
dl.onDisable();
} catch (Throwable t) {
// bad :)
LogUtil.logSevere("DisableListener (" + dl.getClass().getName() + "): " + t.getClass().getSimpleName() + " / " + t.getMessage());
LogUtil.logSevere(t);
StaticLog.logSevere("DisableListener (" + dl.getClass().getName() + "): " + t.getClass().getSimpleName() + " / " + t.getMessage());
StaticLog.logSevere(t);
}
}
// Write some debug/statistics.
final Counters counters = getGenericInstance(Counters.class);
if (verbose && counters != null) {
LogUtil.logInfo(counters.getMergedCountsString(true));
StaticLog.logInfo(counters.getMergedCountsString(true));
}
// Hooks:
@ -601,7 +601,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Unregister all added components explicitly.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Unregister all registered components...");
StaticLog.logInfo("[NoCheatPlus] Unregister all registered components...");
}
final ArrayList<Object> allComponents = new ArrayList<Object>(this.allComponents);
for (int i = allComponents.size() - 1; i >= 0; i--){
@ -610,12 +610,12 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Cleanup BlockProperties.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Cleanup BlockProperties...");
StaticLog.logInfo("[NoCheatPlus] Cleanup BlockProperties...");
}
BlockProperties.cleanup();
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Cleanup some mappings...");
StaticLog.logInfo("[NoCheatPlus] Cleanup some mappings...");
}
// Remove listeners.
listeners.clear();
@ -641,22 +641,22 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// Cleanup the configuration manager.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Cleanup ConfigManager...");
StaticLog.logInfo("[NoCheatPlus] Cleanup ConfigManager...");
}
ConfigManager.cleanup();
// Cleanup file logger.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] Cleanup file logger...");
StaticLog.logInfo("[NoCheatPlus] Cleanup file logger...");
}
StaticLogFile.cleanup();
// Tell the server administrator the we finished unloading NoCheatPlus.
if (verbose) {
LogUtil.logInfo("[NoCheatPlus] All cleanup done.");
StaticLog.logInfo("[NoCheatPlus] All cleanup done.");
}
final PluginDescriptionFile pdfFile = getDescription();
LogUtil.logInfo("[NoCheatPlus] Version " + pdfFile.getVersion() + " is disabled.");
StaticLog.logInfo("[NoCheatPlus] Version " + pdfFile.getVersion() + " is disabled.");
}
/**
@ -848,7 +848,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
configProblems = Updates.isConfigUpToDate(config);
if (configProblems != null && config.getBoolean(ConfPaths.CONFIGVERSION_NOTIFY)){
// Could use custom prefix from logging, however ncp should be mentioned then.
LogUtil.logWarning("[NoCheatPlus] " + configProblems);
StaticLog.logWarning("[NoCheatPlus] " + configProblems);
}
// Care for already online players.
@ -880,21 +880,21 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
});
// Tell the server administrator that we finished loading NoCheatPlus now.
LogUtil.logInfo("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
StaticLog.logInfo("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
}
/**
* Actions to be done after enable of all plugins. This aims at reloading mainly.
*/
private void postEnable(final Player[] onlinePlayers, Runnable... runnables){
LogUtil.logInfo("[NoCheatPlus] Post-enable running...");
StaticLog.logInfo("[NoCheatPlus] Post-enable running...");
for (final Runnable runnable : runnables){
try{
runnable.run();
}
catch(Throwable t){
LogUtil.logSevere("[NoCheatPlus] Encountered a problem during post-enable: " + t.getClass().getSimpleName());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] Encountered a problem during post-enable: " + t.getClass().getSimpleName());
StaticLog.logSevere(t);
}
}
for (final Player player : onlinePlayers){
@ -905,7 +905,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
}
}
// TODO: if (online.lenght > 0) LogUtils.logInfo("[NCP] Updated " + online.length + "players (post-enable).")
LogUtil.logInfo("[NoCheatPlus] Post-enable finished.");
StaticLog.logInfo("[NoCheatPlus] Post-enable finished.");
}
/**
@ -988,12 +988,12 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
try{
((MCAccessHolder) obj).setMCAccess(mcAccess);
} catch(Throwable t){
LogUtil.logSevere("[NoCheatPlus] MCAccessHolder(" + obj.getClass().getName() + ") failed to set MCAccess: " + t.getClass().getSimpleName());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] MCAccessHolder(" + obj.getClass().getName() + ") failed to set MCAccess: " + t.getClass().getSimpleName());
StaticLog.logSevere(t);
}
}
}
LogUtil.logInfo("[NoCheatPlus] McAccess set to: " + mcAccess.getMCVersion() + " / " + mcAccess.getServerVersionTag());
StaticLog.logInfo("[NoCheatPlus] McAccess set to: " + mcAccess.getMCVersion() + " / " + mcAccess.getServerVersionTag());
}
/**
@ -1092,8 +1092,8 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
jlListener.playerJoins(player);
}
catch(Throwable t){
LogUtil.logSevere("[NoCheatPlus] JoinLeaveListener(" + jlListener.getClass().getName() + ") generated an exception (join): " + t.getClass().getSimpleName());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] JoinLeaveListener(" + jlListener.getClass().getName() + ") generated an exception (join): " + t.getClass().getSimpleName());
StaticLog.logSevere(t);
}
}
// Mod message (left on low instead of lowest to allow some permissions plugins compatibility).
@ -1109,8 +1109,8 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
jlListener.playerLeaves(player);
}
catch(Throwable t){
LogUtil.logSevere("[NoCheatPlus] JoinLeaveListener(" + jlListener.getClass().getName() + ") generated an exception (leave): " + t.getClass().getSimpleName());
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] JoinLeaveListener(" + jlListener.getClass().getName() + ") generated an exception (leave): " + t.getClass().getSimpleName());
StaticLog.logSevere(t);
}
}
}
@ -1167,8 +1167,8 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
checker.checkConsistency(onlinePlayers);
}
catch (Throwable t){
LogUtil.logSevere("[NoCheatPlus] ConsistencyChecker(" + checker.getClass().getName() + ") encountered an exception:");
LogUtil.logSevere(t);
StaticLog.logSevere("[NoCheatPlus] ConsistencyChecker(" + checker.getClass().getName() + ") encountered an exception:");
StaticLog.logSevere(t);
}
consistencyCheckerIndex ++; // Do not remove :).
final long now = System.currentTimeMillis();
@ -1189,11 +1189,11 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
}
});
if (debug){
LogUtil.logInfo("[NoCheatPlus] Re-scheduled consistency-checks.");
StaticLog.logInfo("[NoCheatPlus] Re-scheduled consistency-checks.");
}
}
else if (debug){
LogUtil.logInfo("[NoCheatPlus] Consistency-checks run.");
StaticLog.logInfo("[NoCheatPlus] Consistency-checks run.");
}
}

View File

@ -6,7 +6,7 @@ import java.util.List;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.checks.inventory.FastConsume;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.net.protocollib.ProtocolLibComponent;
/**
@ -32,14 +32,14 @@ public class DefaultComponentFactory {
available.add(new FastConsume());
}
catch (Throwable t){
LogUtil.logInfo("[NoCheatPlus] Inventory checks: FastConsume is not available.");
StaticLog.logInfo("[NoCheatPlus] Inventory checks: FastConsume is not available.");
}
// ProtocolLib dependencies.
try {
available.add(new ProtocolLibComponent(plugin));
} catch (Throwable t){
LogUtil.logInfo("[NoCheatPlus] Packet level access: ProtocolLib is not available.");
StaticLog.logInfo("[NoCheatPlus] Packet level access: ProtocolLib is not available.");
}
return available;

View File

@ -22,7 +22,7 @@ import fr.neatmonster.nocheatplus.compat.cb3100.MCAccessCB3100;
import fr.neatmonster.nocheatplus.compat.glowstone.MCAccessGlowstone;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
/**
* Factory class to hide potentially dirty stuff.
@ -76,12 +76,12 @@ public class MCAccessFactory {
else{
msg = "[NoCheatPlus] Could not set up native access for the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support.";
for (String uMsg : updateLocs) {
LogUtil.logWarning(uMsg);
StaticLog.logWarning(uMsg);
}
}
LogUtil.logWarning(msg);
StaticLog.logWarning(msg);
final MCAccess mcAccess = new MCAccessBukkit();
LogUtil.logWarning("[NoCheatPlus] Bukkit-API-only access: Some features will likely not function properly, performance might suffer.");
StaticLog.logWarning("[NoCheatPlus] Bukkit-API-only access: Some features will likely not function properly, performance might suffer.");
return mcAccess;
}
catch(Throwable t) {
@ -90,13 +90,13 @@ public class MCAccessFactory {
// All went wrong.
// TODO: Fall-back solution (disable plugin, disable checks).
LogUtil.logSevere("[NoCheatPlus] Your version of NoCheatPlus is not compatible with the version of the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support.");
StaticLog.logSevere("[NoCheatPlus] Your version of NoCheatPlus is not compatible with the version of the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support.");
for (String msg : updateLocs) {
LogUtil.logSevere(msg);
StaticLog.logSevere(msg);
}
LogUtil.logSevere("[NoCheatPlus] >>> Failed to set up MCAccess <<<");
StaticLog.logSevere("[NoCheatPlus] >>> Failed to set up MCAccess <<<");
for (Throwable t : throwables ) {
LogUtil.logSevere(t);
StaticLog.logSevere(t);
}
// TODO: Schedule disabling the plugin or running in circles.
throw new RuntimeException("Could not set up native access to the server mod, neither to the Bukkit-API.");

View File

@ -3,7 +3,7 @@ package fr.neatmonster.nocheatplus.test;
import org.bukkit.Material;
import org.junit.Test;
import fr.neatmonster.nocheatplus.logging.LogUtil;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.FakeBlockCache;
import fr.neatmonster.nocheatplus.utilities.PassableRayTracing;
@ -17,9 +17,9 @@ public class TestPassableRayTracing {
// TODO: Randomized tests (Collide with inner sphere, not collide with outer sphere).
public TestPassableRayTracing() {
LogUtil.setUseBukkitLogger(false);
StaticLog.setUseBukkitLogger(false);
BlockTests.initBlockProperties();
LogUtil.setUseBukkitLogger(true);
StaticLog.setUseBukkitLogger(true);
}
@Test