use of cloud.commandframework.annotations.CommandMethod in project Insights by InsightsPlugin.
the class CommandScanHistory method handleScanHistory.
@CommandMethod("scanhistory <page>")
@CommandPermission("insights.scanregion.tile")
private void handleScanHistory(Player player, @Argument("page") Page page) {
UUID uuid = player.getUniqueId();
Optional<Messages.PaginatedMessage<?>> historyOptional = plugin.getScanHistory().getHistory(uuid);
if (historyOptional.isPresent()) {
historyOptional.get().sendTo(player, page.page);
} else {
plugin.getMessages().getMessage(Messages.Key.SCANHISTORY_NO_HISTORY).sendTo(player);
}
}
use of cloud.commandframework.annotations.CommandMethod in project Insights by InsightsPlugin.
the class CommandScan method handleCustomScan.
@CommandMethod("custom <items>")
@CommandPermission("insights.scan.custom")
private void handleCustomScan(Player player, @Argument("radius") @Range(min = "0", max = "256") int radius, @Flag(value = "group-by-chunk", aliases = { "c" }) boolean groupByChunk, @Argument("items") ScanObject<?>[] items) {
List<ScanObject<?>> scanObjects = Arrays.asList(items);
boolean hasOnlyEntities = scanObjects.stream().allMatch(s -> s.getType() == ScanObject.Type.ENTITY);
boolean hasOnlyMaterials = scanObjects.stream().allMatch(s -> s.getType() == ScanObject.Type.MATERIAL);
ScanOptions options;
if (hasOnlyEntities) {
options = ScanOptions.entitiesOnly();
} else if (hasOnlyMaterials) {
options = ScanOptions.materialsOnly();
} else {
options = ScanOptions.scanOnly();
}
handleScan(player, radius, new HashSet<>(scanObjects), options, true, groupByChunk);
}
use of cloud.commandframework.annotations.CommandMethod in project Insights by InsightsPlugin.
the class CommandInsights method displayStatistics.
@CommandMethod("stats")
@CommandPermission("insights.stats")
private void displayStatistics(CommandSender sender) {
ContainerExecutorService executor = ((Insights) plugin).getExecutor();
plugin.getMessages().getMessage(Messages.Key.STATS).addTemplates(Messages.tagOf("chunks_scanned", StringUtils.pretty(executor.getCompletedTaskCount())), Messages.tagOf("blocks_scanned", StringUtils.pretty(plugin.getMetricsManager().getTotalBlocksScanned().sum())), Messages.tagOf("queue_size", StringUtils.pretty(executor.getQueueSize()))).sendTo(sender);
}
use of cloud.commandframework.annotations.CommandMethod in project Insights by InsightsPlugin.
the class CommandScanCache method handleCacheClear.
@CommandMethod("clear")
@CommandPermission("insights.scancache.clear")
private void handleCacheClear(Player player) {
Location loc = player.getLocation();
Optional<Region> optionalRegion = plugin.getAddonManager().getRegion(loc);
// If a region is present, try to delete cache of the region.
if (optionalRegion.isPresent()) {
plugin.getAddonStorage().remove(optionalRegion.get().getKey());
} else {
plugin.getWorldStorage().getWorld(loc.getWorld().getUID()).remove(ChunkUtils.getKey(loc.getChunk()));
}
String areaName = optionalRegion.map(r -> plugin.getAddonManager().getAddon(r.getAddon()).getAreaName()).orElse("chunk");
plugin.getMessages().getMessage(Messages.Key.SCANCACHE_CLEARED).addTemplates(Messages.tagOf("area", areaName)).sendTo(player);
}
Aggregations