Skip to content

Commit

Permalink
Replace 'volatile int' to 'AtomicInteger' (Security for multiplayer)
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Dec 18, 2024
1 parent 0ddf616 commit cedce36
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.imesense.dynamicspawncontrol.core.logfile.Log;
import org.imesense.dynamicspawncontrol.core.util.CodeGeneric;

import java.util.concurrent.atomic.AtomicInteger;

/**
*
*/
Expand All @@ -25,12 +27,12 @@ public final class OnEventOvergrowingGrass
/**
*
*/
private static volatile int _TICK_COUNTER = 0;
private static boolean instanceExists = false;

/**
*
*/
private static boolean instanceExists = false;
private static final AtomicInteger TICK_COUNTER = new AtomicInteger(0);

/**
*
Expand Down Expand Up @@ -60,12 +62,12 @@ public static void onWorldTick_0(TickEvent.WorldTickEvent worldTickEvent)
return;
}

if (++_TICK_COUNTER < 20)
if (TICK_COUNTER.incrementAndGet() < 20)
{
return;
}

_TICK_COUNTER = 0;
TICK_COUNTER.set(0);

World world = worldTickEvent.world;

Expand Down

0 comments on commit cedce36

Please sign in to comment.