Skip to content

Commit

Permalink
- chatSpamThresholdCount -> field_147374_l
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Jun 3, 2024
1 parent 4fdce2e commit f79d9c1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
- private int field_147374_l;
+ // private int chatSpamThresholdCount;
+ // CraftBukkit start - multithreaded fields
+ private volatile int chatSpamThresholdCount;
+ private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(NetHandlerPlayServer.class, FMLLaunchHandler.isDeobfuscatedEnvironment() ? "chatSpamThresholdCount" : "chatSpamThresholdCount");
+ private volatile int field_147374_l;
+ private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(NetHandlerPlayServer.class, FMLLaunchHandler.isDeobfuscatedEnvironment() ? "chatSpamThresholdCount" : "field_147374_l");
+ // CraftBukkit end
private int field_147375_m;
- private final IntHashMap<Short> field_147372_n = new IntHashMap<>();
Expand Down Expand Up @@ -260,7 +260,7 @@
-
- if (this.field_147374_l > 0)
+ // CraftBukkit start
+ for (int spam; (spam = this.chatSpamThresholdCount) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
+ for (int spam; (spam = this.field_147374_l) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
+ /* Use thread-safe field access instead
+ if (this.chatThrottle > 0)
{
Expand Down

0 comments on commit f79d9c1

Please sign in to comment.