use of fr.neatmonster.nocheatplus.checks.ViolationHistory.VLView in project NoCheatPlus by NoCheatPlus.
the class TopCommand method onCommand.
@SuppressWarnings("unchecked")
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if (args.length < 2) {
return false;
}
int startIndex = 1;
int n = 10;
try {
n = Integer.parseInt(args[1].trim());
startIndex = 2;
} catch (NumberFormatException e) {
}
if (n <= 0) {
sender.sendMessage("Setting number of entries to 10");
n = 1;
} else if ((sender instanceof Player) && n > 300) {
sender.sendMessage("Capping number of entries at 300.");
n = 300;
} else if (n > 10000) {
sender.sendMessage("Capping number of entries at 10000.");
n = 10000;
}
Set<CheckType> checkTypes = new LinkedHashSet<CheckType>();
for (int i = startIndex; i < args.length; i++) {
CheckType type = null;
try {
type = CheckType.valueOf(args[i].trim().toUpperCase().replace('-', '_').replace('.', '_'));
}// ...
catch (Throwable t) {
}
if (type != null) {
// Includes type.
checkTypes.addAll(CheckTypeUtil.getWithDescendants(type));
}
}
if (checkTypes.isEmpty()) {
sender.sendMessage("No check types specified!");
return false;
}
Comparator<VLView> comparator = VLView.parseMixedComparator(args, startIndex);
if (comparator == null) {
// TODO: Default comparator ?
comparator = new FCFSComparator<VLView>(Arrays.asList(VLView.CmpnVL, VLView.CmpSumVL), true);
}
// Run a worker task.
Bukkit.getScheduler().scheduleSyncDelayedTask(access, new PrimaryThreadWorker(sender, checkTypes, comparator, n, access));
return true;
}
Aggregations