mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-09 12:10:37 +01:00
Optimize ActionWithParameters.
Only return true for needsParameters() if a wildcard is present at all.
This commit is contained in:
parent
4cb953e2bb
commit
006d987518
@ -30,6 +30,8 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
/** The parts of the message. */
|
/** The parts of the message. */
|
||||||
protected final ArrayList<Object> messageParts;
|
protected final ArrayList<Object> messageParts;
|
||||||
|
|
||||||
|
protected boolean needsParameters = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new action with parameters.
|
* Instantiates a new action with parameters.
|
||||||
*
|
*
|
||||||
@ -46,12 +48,14 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
super(name, delay, repeat);
|
super(name, delay, repeat);
|
||||||
|
|
||||||
messageParts = new ArrayList<Object>();
|
messageParts = new ArrayList<Object>();
|
||||||
|
// Assume we don't nee parameters.
|
||||||
|
needsParameters = false;
|
||||||
parseMessage(message);
|
parseMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string with all the wildcards replaced with data from the violation data.
|
* Get a string with all the wildcards replaced with data from the violation data.<br>
|
||||||
|
* This should set the flag needsParameters if parameters are actually needed.
|
||||||
*
|
*
|
||||||
* @param violationData
|
* @param violationData
|
||||||
* the violation data
|
* the violation data
|
||||||
@ -99,6 +103,7 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
final ParameterName w = ParameterName.get(parts2[0].toLowerCase());
|
final ParameterName w = ParameterName.get(parts2[0].toLowerCase());
|
||||||
|
|
||||||
if (w != null) {
|
if (w != null) {
|
||||||
|
needsParameters = true;
|
||||||
// Found an existing wildcard in between the braces.
|
// Found an existing wildcard in between the braces.
|
||||||
messageParts.add(parts[0]);
|
messageParts.add(parts[0]);
|
||||||
messageParts.add(w);
|
messageParts.add(w);
|
||||||
@ -113,6 +118,6 @@ public abstract class ActionWithParameters extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsParameters() {
|
public boolean needsParameters() {
|
||||||
return true;
|
return needsParameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user