1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-09-10 06:15:59 +00:00

Fix ConcurrentModificationException caused by timers

This commit is contained in:
Fox2Code
2025-04-29 21:14:14 +02:00
parent 22c094192b
commit 00e57227dc

View File

@@ -203,8 +203,10 @@ public class OSAPI implements ILuaAPI {
*/
@LuaFunction
public final int startTimer(double timer) throws LuaException {
timers.put(nextTimerToken, new Timer((int) Math.round(checkFinite(0, timer) / 0.05)));
return nextTimerToken++;
synchronized (timers) {
timers.put(nextTimerToken, new Timer((int) Math.round(checkFinite(0, timer) / 0.05)));
return nextTimerToken++;
}
}
/**
@@ -217,7 +219,9 @@ public class OSAPI implements ILuaAPI {
*/
@LuaFunction
public final void cancelTimer(int token) {
timers.remove(token);
synchronized (timers) {
timers.remove(token);
}
}
/**