forked from InsightsPlugin/Insights
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIExample.java
More file actions
49 lines (39 loc) · 1.58 KB
/
Copy pathAPIExample.java
File metadata and controls
49 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package net.frankheijden.insights.api;
import net.frankheijden.insights.builders.Scanner;
import net.frankheijden.insights.entities.*;
import net.frankheijden.insights.enums.ScanType;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.List;
public class APIExample {
public void performScan() {
ScanOptions options = new ScanOptions();
options.setScanType(ScanType.CUSTOM);
// Let's scan in world
World world = Bukkit.getWorld("world");
options.setWorld(world);
// Let's scan the whole world
List<ChunkLocation> chunkLocations = ChunkLocation.from(world.getLoadedChunks());
options.setPartialChunks(PartialChunk.from(world, chunkLocations));
// Let's scan for ores!
options.addMaterial("DIAMOND_ORE");
options.addMaterial("EMERALD_ORE");
options.addMaterial("GOLD_ORE");
options.addMaterial("LAPIS_ORE");
options.addMaterial("IRON_ORE");
options.addMaterial("COAL_ORE");
// Let's also scan for creepers and spiders!
options.addEntityType("CREEPER");
options.addEntityType("SPIDER");
// Let's scan!
Scanner.create(options).scan().whenComplete((event, err) -> {
// This block is called when the scan has completed
ScanResult result = event.getScanResult();
// And print the result to the console
System.out.println("Scan Result:");
result.getCounts().forEach((key, value) -> {
System.out.println(key + ": " + value);
});
});
}
}