Search in sources :

Example 1 with ScanOptions

use of dev.frankheijden.insights.api.concurrent.ScanOptions 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);
}
Also used : ScanObject(dev.frankheijden.insights.api.objects.wrappers.ScanObject) ScanOptions(dev.frankheijden.insights.api.concurrent.ScanOptions) CommandMethod(cloud.commandframework.annotations.CommandMethod) CommandPermission(cloud.commandframework.annotations.CommandPermission)

Aggregations

CommandMethod (cloud.commandframework.annotations.CommandMethod)1 CommandPermission (cloud.commandframework.annotations.CommandPermission)1 ScanOptions (dev.frankheijden.insights.api.concurrent.ScanOptions)1 ScanObject (dev.frankheijden.insights.api.objects.wrappers.ScanObject)1