mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 19:07:45 +01:00
Allow parameters to be set in ViolationData, even if not "needed".
This allows to add parameters in case of debugging, to display them. Also addid is a hasParameters method, which checks if any are set.
This commit is contained in:
parent
d9897191de
commit
d365cd5b75
@ -15,7 +15,7 @@ public interface ParameterHolder extends ActionData{
|
|||||||
public String getParameter(final ParameterName parameterName);
|
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 parameterName
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@ -23,7 +23,13 @@ public interface ParameterHolder extends ActionData{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any of the actions needs parameters.
|
* 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();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks;
|
package fr.neatmonster.nocheatplus.checks;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -49,7 +50,9 @@ public class ViolationData implements IViolationInfo, ActionData{
|
|||||||
public final double vL;
|
public final double vL;
|
||||||
|
|
||||||
/** Filled in parameters. */
|
/** Filled in parameters. */
|
||||||
private final Map<ParameterName, String> parameters;
|
private Map<ParameterName, String> parameters;
|
||||||
|
|
||||||
|
private boolean needsParameters = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new violation data.
|
* Instantiates a new violation data.
|
||||||
@ -81,6 +84,7 @@ public class ViolationData implements IViolationInfo, ActionData{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
parameters = needsParameters ? check.getParameterMap(this) : null;
|
parameters = needsParameters ? check.getParameterMap(this) : null;
|
||||||
|
this.needsParameters = needsParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,12 +154,20 @@ public class ViolationData implements IViolationInfo, ActionData{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameter(final ParameterName parameterName, String value){
|
public void setParameter(final ParameterName parameterName, String value){
|
||||||
if (parameters != null) parameters.put(parameterName, value);
|
if (parameters == null) {
|
||||||
|
parameters = new HashMap<ParameterName, String>();
|
||||||
|
}
|
||||||
|
parameters.put(parameterName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsParameters() {
|
public boolean needsParameters() {
|
||||||
return parameters != null;
|
return needsParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasParameters() {
|
||||||
|
return parameters != null && !parameters.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user