Make sure the found chunk stays loaded

This is done by adding a plugin chunk ticket and removing it once our logic is done
This commit is contained in:
Phoenix616 2023-02-04 14:19:15 +01:00
parent 548d873790
commit 11cbc0abb8
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 33 additions and 28 deletions

View File

@ -455,6 +455,8 @@ public class RandomSearcher {
checkRandom(future);
return false;
}
c.addPluginChunkTicket(plugin);
try {
int indexOffset = random.nextInt(RANDOM_LIST.size());
Location foundLoc = null;
for (int i = 0; i < RANDOM_LIST.size(); i++) {
@ -490,6 +492,9 @@ public class RandomSearcher {
checkRandom(future);
}
return false;
} finally {
c.removePluginChunkTicket(plugin);
}
}).exceptionally(future::completeExceptionally);
}