Skip to content

Commit e1e9509

Browse files
Copilotptthanh02
andcommitted
Use blocking lock for dataLock to prevent skipped cycles during stack size updates
Co-authored-by: ptthanh02 <73684260+ptthanh02@users.noreply.github.com>
1 parent 57b43bb commit e1e9509

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

core/src/main/java/github/nighter/smartspawner/spawner/lootgen/SpawnerLootGenerator.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,13 @@ public void spawnLootToSpawner(SpawnerData spawner) {
9090

9191
try {
9292
final long currentTime = System.currentTimeMillis();
93-
94-
boolean dataLockAcquired = false;
95-
try {
96-
dataLockAcquired = spawner.getDataLock().tryLock(50, java.util.concurrent.TimeUnit.MILLISECONDS);
97-
} catch (InterruptedException e) {
98-
Thread.currentThread().interrupt();
99-
return;
100-
}
101-
102-
if (!dataLockAcquired) {
103-
boolean resetLockAcquired = spawner.getDataLock().tryLock();
104-
if (resetLockAcquired) {
105-
try {
106-
spawner.setLastSpawnTime(currentTime);
107-
} finally {
108-
spawner.getDataLock().unlock();
109-
}
110-
}
111-
return;
112-
}
113-
11493
final long spawnTime;
11594
final int minMobs;
11695
final int maxMobs;
11796
final AtomicInteger usedSlots;
11897
final AtomicInteger maxSlots;
11998

99+
spawner.getDataLock().lock();
120100
try {
121101
long lastSpawnTime = spawner.getLastSpawnTime();
122102
long spawnDelay = spawner.getSpawnDelay();

0 commit comments

Comments
 (0)