Improve display of /reportstat
This commit is contained in:
parent
bbb40a7b6e
commit
779efe3f47
@ -1,8 +1,22 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
public enum ReportRole
|
||||
{
|
||||
SUSPECT,
|
||||
REPORTER,
|
||||
HANDLER
|
||||
HANDLER;
|
||||
|
||||
private final String _humanName;
|
||||
|
||||
ReportRole()
|
||||
{
|
||||
_humanName = WordUtils.capitalize(name().toLowerCase().replace('_', ' '));
|
||||
}
|
||||
|
||||
public String getHumanName()
|
||||
{
|
||||
return _humanName;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,6 +14,9 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.report.ReportRole;
|
||||
import mineplex.core.report.data.Report;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* A staff command for viewing report related statistics of a player.
|
||||
@ -35,13 +40,24 @@ public class ReportStatCommand extends CommandBase<ReportPlugin>
|
||||
{
|
||||
int accountId = _commandCenter.GetClientManager().getAccountId(target);
|
||||
|
||||
// TODO
|
||||
Plugin.getReportManager().getStatistics(accountId).thenCompose(BukkitFuture.accept(stats ->
|
||||
stats.keySet().forEach(role ->
|
||||
{
|
||||
caller.sendMessage(F.elem(role.name()));
|
||||
List<String> reportIds = stats.get(role)
|
||||
.stream()
|
||||
.map(Report::getId)
|
||||
.filter(Optional::isPresent)
|
||||
.limit(5)
|
||||
.map(Optional::get)
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stats.get(role).forEach(report -> caller.sendMessage(String.valueOf(report.getId().orElse(-1L))));
|
||||
// don't show handler statistics if user has never handled a report
|
||||
if (role != ReportRole.HANDLER || reportIds.size() > 0)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.elem(role.getHumanName())));
|
||||
caller.sendMessage(F.main(Plugin.getName(), StringUtils.join(reportIds, ", ")));
|
||||
}
|
||||
})
|
||||
));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user