Use access methods for all normal logging to console.

This commit is contained in:
asofold 2012-09-29 17:12:09 +02:00
parent 704b4e8089
commit 1cbc4ed16c
11 changed files with 38 additions and 20 deletions

View File

@ -45,6 +45,7 @@ import fr.neatmonster.nocheatplus.net.NCPNetServerHandler;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
import fr.neatmonster.nocheatplus.utilities.TickTask;
import fr.neatmonster.nocheatplus.utilities.Updates;
@ -209,7 +210,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
ConfigManager.cleanup();
// Tell the server administrator the we finished unloading NoCheatPlus.
System.out.println("[NoCheatPlus] Version " + pdfFile.getVersion() + " is disabled.");
CheckUtils.logInfo("[NoCheatPlus] Version " + pdfFile.getVersion() + " is disabled.");
}
/* (non-Javadoc)
@ -313,7 +314,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
BlockProperties.dumpBlocks(config.getBoolean(ConfPaths.BLOCKBREAK_FASTBREAK_DEBUG, false));
// Tell the server administrator that we finished loading NoCheatPlus now.
System.out.println("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
CheckUtils.logInfo("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
}
public void onPlayerJoinLow(final PlayerJoinEvent event) {

View File

@ -9,6 +9,7 @@ import fr.neatmonster.nocheatplus.actions.types.CancelAction;
import fr.neatmonster.nocheatplus.actions.types.CommandAction;
import fr.neatmonster.nocheatplus.actions.types.DummyAction;
import fr.neatmonster.nocheatplus.actions.types.LogAction;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
/*
* MMP"""""""MM dP oo MM""""""""`M dP
@ -94,7 +95,7 @@ public class ActionFactory {
}
list.setActions(vl, createActions(def.split("\\s+")));
} catch (final Exception e) {
System.out.println("[NoCheatPlus] Couldn't parse action definition 'vl:" + s + "'.");
CheckUtils.logWarning("[NoCheatPlus] Couldn't parse action definition 'vl:" + s + "'.");
}
}
@ -117,7 +118,7 @@ public class ActionFactory {
try {
actions.add(createAction(def));
} catch (final IllegalArgumentException e) {
System.out.println("[NoCheatPlus] " + e.getMessage());
CheckUtils.logWarning("[NoCheatPlus] Failed to create action: " + e.getMessage());
actions.add(new DummyAction(def));
}
}
@ -148,7 +149,7 @@ public class ActionFactory {
delay = Integer.parseInt(parts[1]);
repeat = Integer.parseInt(parts[2]);
} catch (final Exception e) {
System.out.println("[NoCheatPlus] Couldn't parse details of command '" + definition
CheckUtils.logWarning("[NoCheatPlus] Couldn't parse details of command '" + definition
+ "', will use default values instead.");
delay = 0;
repeat = 0;
@ -185,7 +186,7 @@ public class ActionFactory {
toChat = parts[3].contains("i");
toFile = parts[3].contains("f");
} catch (final Exception e) {
System.out.println("[NoCheatPlus] Couldn't parse details of log action '" + definition
CheckUtils.logWarning("[NoCheatPlus] Couldn't parse details of log action '" + definition
+ "', will use default values instead.");
e.printStackTrace();
delay = 0;

View File

@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandException;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
/*
* MM'""""'YMM dP
@ -53,7 +54,7 @@ public class CommandAction extends ActionWithParameters {
try {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
} catch (final CommandException e) {
System.out.println("[NoCheatPlus] Failed to execute the command '" + command + "': " + e.getMessage()
CheckUtils.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

@ -76,7 +76,7 @@ public class LogAction extends ActionWithParameters {
otherPlayer.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE
+ CheckUtils.replaceColors(message));
if (toConsole && configurationFile.getBoolean(ConfPaths.LOGGING_CONSOLE))
System.out.println("[NoCheatPlus] " + CheckUtils.removeColors(message));
CheckUtils.logInfo("[NoCheatPlus] " + CheckUtils.removeColors(message));
if (toFile && configurationFile.getBoolean(ConfPaths.LOGGING_FILE))
CheckUtils.fileLogger.info(CheckUtils.removeColors(message));
}

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.command.DelayableCommand;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
public class BanCommand extends DelayableCommand {
@ -40,7 +41,7 @@ public class BanCommand extends DelayableCommand {
player.kickPlayer(reason);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(name);
offlinePlayer.setBanned(true);
System.out.println("[NoCheatPlus] (" + sender.getName() + ") Banned " + offlinePlayer.getName() + " : " + reason);
CheckUtils.logInfo("[NoCheatPlus] (" + sender.getName() + ") Banned " + offlinePlayer.getName() + " : " + reason);
}
}

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.command.DelayableCommand;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
public class KickCommand extends DelayableCommand {
@ -37,7 +38,7 @@ public class KickCommand extends DelayableCommand {
Player player = Bukkit.getPlayerExact(name);
if (player == null) return;
player.kickPlayer(reason);
System.out.println("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
CheckUtils.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
}
}

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.command.DelayableCommand;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
public class TempKickCommand extends DelayableCommand {
@ -50,6 +51,6 @@ public class TempKickCommand extends DelayableCommand {
NoCheatPlus.denyLogin(name, duration);
if (player == null) return;
player.kickPlayer(reason);
System.out.println("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
CheckUtils.logInfo("[NoCheatPlus] (" + sender.getName() + ") Kicked " + player.getName() + " for " + duration/60000 +" minutes: " + reason);
}
}

View File

@ -454,8 +454,8 @@ public class BlockProperties {
public static void dumpBlocks(boolean all) {
List<String> missing = new LinkedList<String>();
if (all) {
System.out.println("[NoCheatPlus] Dump block properties for fastbreak check:");
System.out.println("--- Present entries -------------------------------");
CheckUtils.logInfo("[NoCheatPlus] Dump block properties for fastbreak check:");
CheckUtils.logInfo("--- Present entries -------------------------------");
}
for (int i = 0; i < blocks.length; i++){
String mat;
@ -471,13 +471,13 @@ public class BlockProperties {
if (mat.equals("?")) continue;
missing.add("* MISSING "+i + "(" + mat +") ");
}
else if (all) System.out.println(i + ": (" + mat + ") " + blocks[i].toString());
else if (all) CheckUtils.logInfo(i + ": (" + mat + ") " + blocks[i].toString());
}
if (!missing.isEmpty()){
Bukkit.getLogger().warning("[NoCheatPlus] The block breaking data is incomplete, interpret some as stone :");
System.out.println("--- Missing entries -------------------------------");
CheckUtils.logWarning("--- Missing entries -------------------------------");
for (String spec : missing){
System.out.println(spec);
CheckUtils.logWarning(spec);
}
}
}

View File

@ -288,4 +288,16 @@ public class CheckUtils {
else if (diff > Math.PI) return diff - 2.0 * Math.PI;
else return diff;
}
public static void logSevere(final String msg) {
Bukkit.getLogger().severe((msg));
}
public static void logWarning(final String msg) {
Bukkit.getLogger().warning((msg));
}
public static void logInfo(final String msg) {
Bukkit.getLogger().info((msg));
}
}

View File

@ -41,7 +41,7 @@ public class LagMeasureTask implements Runnable {
try {
Bukkit.getServer().getScheduler().cancelTask(instance.lagMeasureTaskId);
} catch (final Exception e) {
System.out.println("[NoCheatPlus] Couldn't cancel LagMeasureTask: " + e.getMessage() + ".");
CheckUtils.logWarning("[NoCheatPlus] Couldn't cancel LagMeasureTask: " + e.getMessage() + ".");
}
instance.lagMeasureTaskId = -1;
}
@ -98,9 +98,9 @@ public class LagMeasureTask implements Runnable {
// Show the debug messages.
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_DEBUG))
if (oldStatus != skipCheck && skipCheck)
System.out.println("[NoCheatPlus] Detected server lag, some checks will not work.");
CheckUtils.logInfo("[NoCheatPlus] Detected server lag, some checks will not work.");
else if (oldStatus != skipCheck && !skipCheck)
System.out.println("[NoCheatPlus] Server lag seems to have stopped, reenabling checks.");
CheckUtils.logInfo("[NoCheatPlus] Server lag seems to have stopped, reenabling checks.");
final long time = System.currentTimeMillis();
lastInGameSecondDuration = time - lastInGameSecondTime;

View File

@ -81,7 +81,7 @@ public final class Stats {
if ( ts > tsStats+periodStats){
tsStats = ts;
// print out stats !
System.out.println(getStatsStr());
CheckUtils.logInfo(getStatsStr());
}
}
}