use of fr.neatmonster.nocheatplus.actions.ParameterName in project NoCheatPlus by NoCheatPlus.
the class AllViolationsHook method log.
private void log(final CheckType checkType, final Player player, final IViolationInfo info, final boolean toTrace, final boolean toNotify) {
// Generate the message.
// TODO: More colors?
final StringBuilder builder = new StringBuilder(300);
final String playerName = player.getName();
builder.append("[VL] [" + checkType.toString() + "] ");
builder.append("[" + ChatColor.YELLOW + playerName);
builder.append(ChatColor.WHITE + "] ");
final String displayName = ChatColor.stripColor(player.getDisplayName()).trim();
if (!playerName.equals(displayName)) {
builder.append("[->" + ChatColor.YELLOW + displayName + ChatColor.WHITE + "] ");
}
builder.append("VL=" + StringUtil.fdec1.format(info.getTotalVl()));
builder.append("(+" + StringUtil.fdec1.format(info.getAddedVl()) + ")");
builder.append(ChatColor.GRAY);
for (int i = 0; i < parameters.length; i++) {
final ParameterName name = parameters[i];
final String value = info.getParameter(name);
if (value != null && !value.isEmpty() && !value.equals(this.noParameterTexts[i])) {
builder.append(" " + name.getText() + "=" + value);
}
}
final String message = builder.toString();
// Send the message.
final LogManager logManager = NCPAPIProvider.getNoCheatPlusAPI().getLogManager();
if (toNotify) {
logManager.info(Streams.NOTIFY_INGAME, message);
}
if (toTrace) {
logManager.info(Streams.TRACE_FILE, ChatColor.stripColor(message));
}
}
use of fr.neatmonster.nocheatplus.actions.ParameterName in project NoCheatPlus by NoCheatPlus.
the class ActionWithParameters method parseMessage.
/**
* Parses the message.
*
* @param message
* the message
*/
protected void parseMessage(final String message) {
final String[] parts = message.split("\\[", 2);
// No opening braces left.
if (parts.length != 2)
messageParts.add(message);
else {
final String[] parts2 = parts[1].split("\\]", 2);
// Found no matching closing brace.
if (parts2.length != 2)
messageParts.add(message);
else {
final ParameterName w = ParameterName.get(parts2[0].toLowerCase());
if (w != null) {
needsParameters = true;
// Found an existing wildcard in between the braces.
messageParts.add(parts[0]);
messageParts.add(w);
// Go further down recursive.
parseMessage(parts2[1]);
} else
messageParts.add(message);
}
}
}
Aggregations