@@ -333,23 +333,26 @@ object TranslatorManager {
333333 else true
334334 }
335335
336- CompletableFuture .supplyAsync {
337- batchTranslateLines(translations.map { it.text }, from, to)
338- }
339- .whenCompleteAsync { t, u ->
340- translations.forEachIndexed { i, translation ->
341- if (t != null && u == null ) {
342- broadcastIncomplete(false , translation)
343- translation.future.completeAsync { t[i] }
344- } else {
345- if (translation.player is ServerPlayer ) {
346- broadcastIncomplete(true , translation)
336+ translations.chunked(LibreTranslateInstance .MAX_CONCURRENT_TRANSLATIONS )
337+ .forEach { spliced ->
338+ CompletableFuture .supplyAsync {
339+ batchTranslateLines(spliced.map { it.text }, from, to)
340+ }
341+ .whenCompleteAsync { t, u ->
342+ spliced.forEachIndexed { i, translation ->
343+ if (t != null && u == null ) {
344+ broadcastIncomplete(false , translation)
345+ translation.future.completeAsync { t[i] }
346+ } else {
347+ if (translation.player is ServerPlayer ) {
348+ broadcastIncomplete(true , translation)
349+ }
350+
351+ translation.attempts++
352+ queueLater.add(translation)
353+ }
347354 }
348-
349- translation.attempts++
350- queueLater.add(translation)
351355 }
352- }
353356 }
354357 }
355358
0 commit comments