Skip to content

Commit 78fafa1

Browse files
Fix Incorrect Variable Change Queue Processing (#8182)
Fix incorrect change processing order
1 parent 3965351 commit 78fafa1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main/java/ch/njol/skript/variables/Variables.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,14 @@ public static void setVariable(String name, @Nullable Object value, @Nullable Ev
602602
* @param value the value, or {@code null} to delete the variable.
603603
*/
604604
static void setVariable(String name, @Nullable Object value) {
605-
boolean gotLock = variablesLock.writeLock().tryLock();
606-
if (gotLock) {
605+
if (variablesLock.writeLock().tryLock()) {
607606
try {
608-
// Set the variable
607+
if (!changeQueue.isEmpty()) { // Process older, queued changes if available
608+
processChangeQueue();
609+
}
610+
// Process and save requested change
609611
variables.setVariable(name, value);
610-
// ..., save the variable change
611612
saveVariableChange(name, value);
612-
// ..., and process all previously queued changes
613-
processChangeQueue();
614613
} finally {
615614
variablesLock.writeLock().unlock();
616615
}

0 commit comments

Comments
 (0)