more state checking

This commit is contained in:
mcrcortex
2025-06-02 12:23:06 +10:00
parent 9d0cf33a45
commit e7c4d6f132

View File

@@ -163,15 +163,18 @@ public class WorldEngine {
}
public void markActive() {
if (!this.isLive) throw new IllegalStateException();
this.lastActiveTime = System.currentTimeMillis();
}
public void acquireRef() {
if (!this.isLive) throw new IllegalStateException();
this.refCount.incrementAndGet();
this.lastActiveTime = System.currentTimeMillis();
}
public void releaseRef() {
if (!this.isLive) throw new IllegalStateException();
if (this.refCount.decrementAndGet()<0) {
throw new IllegalStateException("ref count less than 0");
}