From 4a26f741df9c6791f168f236407085ce03792b8b Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 30 Sep 2012 13:54:26 +0200 Subject: [PATCH] Small adjustments for logging. --- .../actions/types/ActionWithParameters.java | 15 +++++++++++---- .../nocheatplus/checks/ViolationData.java | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/actions/types/ActionWithParameters.java b/src/fr/neatmonster/nocheatplus/actions/types/ActionWithParameters.java index 1916011a..923977fa 100644 --- a/src/fr/neatmonster/nocheatplus/actions/types/ActionWithParameters.java +++ b/src/fr/neatmonster/nocheatplus/actions/types/ActionWithParameters.java @@ -59,13 +59,20 @@ public abstract class ActionWithParameters extends Action { */ protected String getMessage(final ViolationData violationData) { // Should be big enough most of the time. - final StringBuilder log = new StringBuilder(100); + final StringBuilder log = new StringBuilder(150); for (final Object part : messageParts) if (part instanceof String) log.append((String) part); - else - log.append(violationData.getParameter((ParameterName) part)); + else if (part == null) log.append("[???]"); + else{ + try{ + log.append(violationData.getParameter((ParameterName) part)); + } + catch (Exception e){ + log.append(part.toString()); + } + } return log.toString(); } @@ -89,7 +96,7 @@ public abstract class ActionWithParameters extends Action { if (parts2.length != 2) messageParts.add(message); else { - final ParameterName w = ParameterName.get(parts2[0]); + final ParameterName w = ParameterName.get(parts2[0].toLowerCase()); if (w != null) { // Found an existing wildcard inbetween the braces. diff --git a/src/fr/neatmonster/nocheatplus/checks/ViolationData.java b/src/fr/neatmonster/nocheatplus/checks/ViolationData.java index 8199f498..f8bc172d 100644 --- a/src/fr/neatmonster/nocheatplus/checks/ViolationData.java +++ b/src/fr/neatmonster/nocheatplus/checks/ViolationData.java @@ -131,13 +131,14 @@ public class ViolationData { * @return Will always return some string, if not set: "". */ public String getParameter(final ParameterName parameterName){ + if (parameterName == null) return ""; switch (parameterName) { case CHECK: return check.getClass().getSimpleName(); case PLAYER: return player.getName(); case VIOLATIONS: - return String.valueOf(Math.round(vL)); + return String.valueOf((long) Math.round(vL)); default: break; }