diff --git a/NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/LinkedHashMapCOW.java b/NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/corw/LinkedHashMapCOW.java similarity index 98% rename from NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/LinkedHashMapCOW.java rename to NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/corw/LinkedHashMapCOW.java index 566857f8..ea74c668 100644 --- a/NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/LinkedHashMapCOW.java +++ b/NCPCommons/src/main/java/fr/neatmonster/nocheatplus/utilities/ds/corw/LinkedHashMapCOW.java @@ -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; diff --git a/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/FastConsume.java b/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/FastConsume.java index 12f5bf15..ee4cefa7 100644 --- a/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/FastConsume.java +++ b/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/checks/inventory/FastConsume.java @@ -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) diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/FlyingFrequency.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/FlyingFrequency.java index fc90e5e8..b2c2b422 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/FlyingFrequency.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/FlyingFrequency.java @@ -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 diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/ProtocolLibComponent.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/ProtocolLibComponent.java index 4e37026d..b5416537 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/ProtocolLibComponent.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/net/protocollib/ProtocolLibComponent.java @@ -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 registeredPacketAdapters = new LinkedList(); 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(); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/AbstractActionFactory.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/AbstractActionFactory.java index 0377ab76..ccdd4210 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/AbstractActionFactory.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/AbstractActionFactory.java @@ -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 >{ @@ -70,7 +70,7 @@ public abstract class AbstractActionFactory (def)); } } @@ -125,7 +125,7 @@ public abstract class AbstractActionFactory { 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)); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java index 4bb1a984..abd55aff 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java @@ -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.
@@ -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; } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Text.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Text.java index f6cbf3b9..eeb5133c 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Text.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Text.java @@ -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(); } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java index 7fa8620d..b30bd4a3 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java @@ -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; } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index 3ac7dc29..c4e13d6b 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -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); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index f9f20477..c1472b77 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -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; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/VehicleSetBack.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/VehicleSetBack.java index e4bafd8e..5d945896 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/VehicleSetBack.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/VehicleSetBack.java @@ -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); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/CommandUtil.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/CommandUtil.java index 8f1f1b19..a53c282c 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/CommandUtil.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/CommandUtil.java @@ -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; } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/BanCommand.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/BanCommand.java index f0f0edba..73bbc060 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/BanCommand.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/BanCommand.java @@ -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) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/DenyLoginCommand.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/DenyLoginCommand.java index 3357ad31..4bb6ab2b 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/DenyLoginCommand.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/DenyLoginCommand.java @@ -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) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/KickCommand.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/KickCommand.java index 18c27e08..69e571c1 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/KickCommand.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/command/actions/KickCommand.java @@ -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) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java index a8792b72..30d93759 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java @@ -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); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_5.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_5.java index 1492b228..423d95ab 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_5.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_5.java @@ -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."); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_6_1.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_6_1.java index 9e806ad2..203a5c54 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_6_1.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_6_1.java @@ -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."); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_7_2.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_7_2.java index 46be2137..70c167be 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_7_2.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_7_2.java @@ -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."); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_8.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_8.java index dc4c3d56..beef36e9 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_8.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_8.java @@ -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."); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/VanillaBlocksFactory.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/VanillaBlocksFactory.java index 8eaf796e..2e222e7b 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/VanillaBlocksFactory.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/VanillaBlocksFactory.java @@ -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; } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java index c6a81030..bab8c572 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfigManager.java @@ -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).
@@ -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); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/PathUtils.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/PathUtils.java index e5d02741..7be3161b 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/PathUtils.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/PathUtils.java @@ -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) { diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/RawConfigFile.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/RawConfigFile.java index 2efe8a09..0aad7881 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/RawConfigFile.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/RawConfigFile.java @@ -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); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/GenericListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/GenericListener.java index ae1d8a68..4ce008fc 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/GenericListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/GenericListener.java @@ -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 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); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/ListenerManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/ListenerManager.java index 3e4c7997..4be1d53d 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/ListenerManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/event/ListenerManager.java @@ -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.
@@ -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 checkedEventType = eventType.asSubclass(Event.class); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/hooks/NCPExemptionManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/hooks/NCPExemptionManager.java index f7db555f..46236fd1 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/hooks/NCPExemptionManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/hooks/NCPExemptionManager.java @@ -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, " | ")); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/LogUtil.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLog.java similarity index 91% rename from NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/LogUtil.java rename to NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLog.java index 378ad211..77ed94d5 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/LogUtil.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLog.java @@ -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) { diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLogFile.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLogFile.java index 8a1007e1..a3e681e6 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLogFile.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/StaticLogFile.java @@ -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; } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java index 84f7844a..0442a856 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/players/DataManager.java @@ -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, " | ")); } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/stats/Timings.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/stats/Timings.java index f2d2696a..8286ce5f 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/stats/Timings.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/stats/Timings.java @@ -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()); } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index ecd4c5ac..75e06f65 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -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 missing = new LinkedList(); 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 tags = new ArrayList(); 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(), "|")); } } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/CheckUtils.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/CheckUtils.java index 549058a1..125ab383 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/CheckUtils.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/CheckUtils.java @@ -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!"); } /** diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TickTask.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TickTask.java index 5c6e877b..bdb880cc 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TickTask.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/TickTask.java @@ -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++) { diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java index 49fc9282..3e7f6c7c 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -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 allComponents = new ArrayList(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."); } } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/DefaultComponentFactory.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/DefaultComponentFactory.java index 883dd949..a1c7d565 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/DefaultComponentFactory.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/DefaultComponentFactory.java @@ -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; diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java index ef75f045..1498ca7e 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java @@ -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."); diff --git a/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestPassableRayTracing.java b/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestPassableRayTracing.java index ac65401e..49755c5a 100644 --- a/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestPassableRayTracing.java +++ b/NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestPassableRayTracing.java @@ -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