mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-28 10:21:22 +01:00
Add name and displayname to ParameterName, handle IP in ViolationData.
This commit is contained in:
parent
9de6061a9e
commit
9a6bb37bd8
@ -4,11 +4,10 @@ package fr.neatmonster.nocheatplus.actions;
|
||||
* Some wildcards that are used in commands and log messages.
|
||||
*/
|
||||
public enum ParameterName {
|
||||
// TODO: Cleanup for some kind of policies: useful names, alternative names, prefer generic names.
|
||||
// TODO: Cleanup for some kind of policies: useful names, alternative names, prefer generic names.
|
||||
BLOCK_ID("blockid"),
|
||||
BLOCK_TYPE("blocktype"),
|
||||
CHECK("check"),
|
||||
TAGS("tags"),
|
||||
DISTANCE("distance"),
|
||||
FALL_DISTANCE("falldistance"), // TODO: rather not deprecate ?
|
||||
FOOD("food"),
|
||||
@ -17,8 +16,11 @@ public enum ParameterName {
|
||||
LOCATION_FROM("locationfrom"),
|
||||
LOCATION_TO("locationto"),
|
||||
PACKETS("packets"),
|
||||
PLAYER("player"), // TODO: playername rather ? + displayname ?
|
||||
PLAYER("player"),
|
||||
PLAYER_DISPLAY_NAME("displayname"),
|
||||
PLAYER_NAME("name"),
|
||||
REACH_DISTANCE("reachdistance"), // TODO: deprecate ?
|
||||
TAGS("tags"),
|
||||
UUID("uuid"),
|
||||
VIOLATIONS("violations"),
|
||||
WORLD("world");
|
||||
@ -50,4 +52,13 @@ public enum ParameterName {
|
||||
private ParameterName(final String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for parsing this parameter in actions.
|
||||
* @return
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -135,20 +135,26 @@ public class ViolationData implements IViolationInfo, ActionData{
|
||||
switch (parameterName) {
|
||||
case CHECK:
|
||||
return check.getClass().getSimpleName();
|
||||
case IP:
|
||||
return player.getAddress().toString().substring(1).split(":")[0];
|
||||
case PLAYER:
|
||||
case PLAYER_NAME:
|
||||
return player.getName();
|
||||
case VIOLATIONS:
|
||||
return String.valueOf((long) Math.round(vL));
|
||||
case PLAYER_DISPLAY_NAME:
|
||||
return player.getDisplayName();
|
||||
case UUID:
|
||||
return player.getUniqueId().toString();
|
||||
case VIOLATIONS:
|
||||
return String.valueOf((long) Math.round(vL));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (parameters == null) {
|
||||
return "<?" + parameterName + ">";
|
||||
// Return what would have been parsed to get the parameter.
|
||||
return "[" + parameterName.getText() + "]";
|
||||
}
|
||||
final String value = parameters.get(parameterName);
|
||||
return(value == null) ? ("<?" + parameterName + ">") : value;
|
||||
return(value == null) ? ("[" + parameterName.getText() + "]") : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,10 +8,8 @@ import java.util.Map;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.checks.chat.analysis.MessageLetterCount;
|
||||
import fr.neatmonster.nocheatplus.checks.chat.analysis.WordLetterCount;
|
||||
import fr.neatmonster.nocheatplus.checks.chat.analysis.engine.LetterEngine;
|
||||
@ -319,11 +317,4 @@ public class Text extends Check implements INotifyReload {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<ParameterName, String> getParameterMap(final ViolationData violationData) {
|
||||
final Map<ParameterName, String> parameters = super.getParameterMap(violationData);
|
||||
parameters.put(ParameterName.IP, violationData.player.getAddress().toString().substring(1).split(":")[0]);
|
||||
return parameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user