diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/ParameterHolder.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/ParameterHolder.java index eda00845..1b2db2e5 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/ParameterHolder.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/actions/ParameterHolder.java @@ -15,7 +15,7 @@ public interface ParameterHolder extends ActionData{ public String getParameter(final ParameterName parameterName); /** - * This might not set any parameters, if needsParameters() returns false. + * This will set the parameter, even if needsParameters() returns false. * @param parameterName * @param value */ @@ -23,7 +23,13 @@ public interface ParameterHolder extends ActionData{ /** * Check if any of the actions needs parameters. - * @return If true, actions are likely to contian command or logging actions. + * @return If true, actions are likely to contain command or logging actions. */ - boolean needsParameters(); + public boolean needsParameters(); + + /** + * Check if any parameters are set (in case of special settings NCP might add parameters for debugging purposes.). + * @return + */ + public boolean hasParameters(); } 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 fb354fb7..fef948ac 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/ViolationData.java @@ -1,5 +1,6 @@ package fr.neatmonster.nocheatplus.checks; +import java.util.HashMap; import java.util.Map; import org.bukkit.entity.Player; @@ -49,7 +50,9 @@ public class ViolationData implements IViolationInfo, ActionData{ public final double vL; /** Filled in parameters. */ - private final Map parameters; + private Map parameters; + + private boolean needsParameters = false; /** * Instantiates a new violation data. @@ -81,6 +84,7 @@ public class ViolationData implements IViolationInfo, ActionData{ } } parameters = needsParameters ? check.getParameterMap(this) : null; + this.needsParameters = needsParameters; } /** @@ -150,15 +154,23 @@ public class ViolationData implements IViolationInfo, ActionData{ @Override public void setParameter(final ParameterName parameterName, String value){ - if (parameters != null) parameters.put(parameterName, value); + if (parameters == null) { + parameters = new HashMap(); + } + parameters.put(parameterName, value); } @Override public boolean needsParameters() { - return parameters != null; + return needsParameters; } - @Override + @Override + public boolean hasParameters() { + return parameters != null && !parameters.isEmpty(); + } + + @Override public double getAddedVl() { return addedVL; }