Don't cache any homes if cache size is <= 0

This commit is contained in:
William committed 2022-09-15 13:51:17 +01:00
1 parent f4a6873ed0
commit f506f0fd00
1 file changed
+4 -1
@@ -98,8 +98,11 @@ public abstract class RandomTeleportEngine {
* @since 3.0
*/
private void populateCache(@NotNull World world, final int cacheSize) {
if (cacheSize <= 0) {
return;
}
CompletableFuture.runAsync(() -> {
final int amountToPopulate = Math.max(1, cacheSize) - cachedPositions.get(world).size();
final int amountToPopulate = cacheSize - cachedPositions.get(world).size();
final Location originLocation = new Location(0, 0, 0, world);
for (int i = 0; i < amountToPopulate; i++) {
generateRandomLocation(originLocation)