use of fr.neatmonster.nocheatplus.checks.ViolationHistory.ViolationLevel in project NoCheatPlus by NoCheatPlus.
the class InfoCommand method handleInfoCommand.
/**
* Handle the '/nocheatplus info' command.
*
* @param sender
* the sender
* @param playerName
* the player name
* @return true, if successful
*/
private void handleInfoCommand(final CommandSender sender, String playerName) {
final Player player = DataManager.getPlayer(playerName);
if (player != null)
playerName = player.getName();
final ViolationHistory history = ViolationHistory.getHistory(playerName, false);
final boolean known = player != null || history != null;
if (history == null) {
sender.sendMessage(TAG + "No entries for " + playerName + "'s violations... " + (known ? "" : "(exact spelling?)") + ".");
return;
}
final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
final ViolationLevel[] violations = history.getViolationLevels();
if (violations.length > 0) {
sender.sendMessage(TAG + "Displaying " + playerName + "'s violations...");
final String c = (sender instanceof Player) ? ChatColor.GRAY.toString() : "";
for (final ViolationLevel violationLevel : violations) {
final long time = violationLevel.time;
final String[] parts = violationLevel.check.split("\\.");
final String check = parts[parts.length - 1].toLowerCase();
final String parent = parts[parts.length - 2].toLowerCase();
final long sumVL = Math.round(violationLevel.sumVL);
final long maxVL = Math.round(violationLevel.maxVL);
final long avVl = Math.round(violationLevel.sumVL / (double) violationLevel.nVL);
sender.sendMessage(TAG + "[" + dateFormat.format(new Date(time)) + "] " + parent + "." + check + " VL " + sumVL + c + " (n" + violationLevel.nVL + "a" + avVl + "m" + maxVL + ")");
}
} else
sender.sendMessage(TAG + "Displaying " + playerName + "'s violations... nothing to display.");
}
Aggregations