File tree 1 file changed +12
-10
lines changed
src/main/java/de/sldk/mc/metrics
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -28,25 +28,27 @@ protected Plugin getPlugin() {
28
28
}
29
29
30
30
public CompletableFuture <Void > collect () {
31
+ return CompletableFuture .runAsync (() -> {
32
+ if (!enabled ) {
33
+ return ;
34
+ }
31
35
32
- if (!enabled ) {
33
- return CompletableFuture .completedFuture (null );
34
- }
36
+ /* If metric is capable of async execution run it on a thread pool */
37
+ if (isAsyncCapable ()) {
35
38
36
- if (isAsyncCapable ()) {
37
- /* If metric is capable of async execution, do it */
38
- return CompletableFuture .runAsync (() -> {
39
39
try {
40
40
doCollect ();
41
41
}
42
42
catch (Exception e ) {
43
43
logException (e );
44
44
}
45
- }) ;
46
- }
45
+ return ;
46
+ }
47
47
48
- /* Otherwise run the metric on the main thread and create a future for this */
49
- return CompletableFuture .runAsync (() -> {
48
+ /*
49
+ * Otherwise run the metric on the main thread and make the
50
+ * thread on thread pool wait for completion
51
+ */
50
52
try {
51
53
Bukkit .getScheduler ().callSyncMethod (plugin , () -> {
52
54
try {
You can’t perform that action at this time.
0 commit comments