package net.minecraft.server; import java.util.concurrent.CompletableFuture; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class SchedulerBatch, R> { private static final Logger a = LogManager.getLogger(); private final Scheduler b; private boolean c; private int d = 1000; private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(true); // Paper public SchedulerBatch(Scheduler scheduler) { this.b = scheduler; } public void a() throws InterruptedException { this.b.b(); } public void startBatch() { b(); } // Paper - OBFHELPER public void b() { lock.lock(); // Paper if (false && this.c) { // Paper throw new RuntimeException("Batch already started."); } else { this.d = 1000; this.c = true; } } public CompletableFuture add(K k0) { return a(k0); } // Paper - OBFHELPER public CompletableFuture a(K k0) { if (!this.c) { throw new RuntimeException("Batch not properly started. Please use startBatch to create a new batch."); } else { CompletableFuture completablefuture = this.b.a(k0); --this.d; if (this.d == 0) { completablefuture = this.b.a(); this.d = 1000; } return completablefuture; } } public CompletableFuture executeBatch() { return c(); } // Paper - OBFHELPER public CompletableFuture c() { // Paper start if (!lock.isHeldByCurrentThread()) { throw new IllegalStateException("Current thread does not hold the write lock"); } try {// Paper end if (false && !this.c) { // Paper throw new RuntimeException("Batch not properly started. Please use startBatch to create a new batch."); } else { if (this.d != 1000) { this.b.a(); } this.c = false; return this.b.c(); } } finally { lock.unlock(); } // Paper } }