Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
Kam committed 2026-02-24 19:12:35 -05:00
commit 3e1b4fd692
31 files changed
+381 -148

No files matched your search

@@ -91,14 +91,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
*/
private transient byte lastSyncedFlags = 0;
/**
* Dirty flag: set when ability data changes (unlock/lock/select/toggle).
* Checked by the periodic 10-tick sync handler, which sends an ability
* data packet and clears the flag. Avoids scattering sync calls across
* every mutation method.
*/
public transient boolean needsSync = false;
/**
* World time when the last ability was activated (for double-press cancel detection).
*/
@@ -497,7 +489,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
@Override
protected void onToggleStateChanged(String key, boolean active, int state) {
needsSync = true;
}
@Override
@@ -534,20 +525,17 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
public void setSelectedIndex(int index) {
if (index == -1 || (index >= 0 && index < unlockedAbilities.size())) {
this.selectedIndex = index;
needsSync = true;
}
}
public void selectNext() {
if (unlockedAbilities.isEmpty()) return;
selectedIndex = (selectedIndex + 1) % unlockedAbilities.size();
needsSync = true;
}
public void selectPrevious() {
if (unlockedAbilities.isEmpty()) return;
selectedIndex = (selectedIndex - 1 + unlockedAbilities.size()) % unlockedAbilities.size();
needsSync = true;
}
public String getSelectedAbilityKey() {
@@ -576,13 +564,11 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
if (selectedIndex >= unlockedAbilities.size()) {
selectedIndex = Math.max(0, unlockedAbilities.size() - 1);
}
needsSync = true;
}
public void unlockAbility(String key) {
if (key != null && !key.isEmpty() && !unlockedAbilities.contains(key)) {
unlockedAbilities.add(key);
needsSync = true;
}
}
@@ -591,7 +577,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
if (selectedIndex >= unlockedAbilities.size()) {
selectedIndex = Math.max(0, unlockedAbilities.size() - 1);
}
needsSync = true;
}
public boolean hasUnlockedAbility(String key) {
@@ -837,7 +822,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
// Reset sync tracking so next sync sends fresh state
lastSyncedFlags = 0;
needsSync = true;
}
/**
@@ -245,8 +245,14 @@ public class PlayerTradeData implements IPlayerTradeData {
* Add a claim to this player's pending claims.
* Thread-safe - can be called from any thread.
*/
public void addClaim(AuctionClaim claim) {
public synchronized void addClaim(AuctionClaim claim) {
if (claim != null && !claim.claimed) {
// Prevent duplicate claim IDs
for (AuctionClaim existing : claims) {
if (existing.id.equals(claim.id)) {
return;
}
}
claims.add(claim);
}
}
@@ -276,8 +282,9 @@ public class PlayerTradeData implements IPlayerTradeData {
/**
* Get a specific claim by ID (internal use).
* Synchronized to pair with claimAndRemove for thread safety.
*/
public AuctionClaim getClaimInternal(String claimId) {
public synchronized AuctionClaim getClaimInternal(String claimId) {
for (AuctionClaim claim : claims) {
if (claim.id.equals(claimId) && !claim.claimed) {
return claim;
@@ -296,8 +303,9 @@ public class PlayerTradeData implements IPlayerTradeData {
/**
* Mark a claim as claimed and remove it.
* Synchronized to prevent double-claim from concurrent threads.
*/
public boolean claimAndRemove(String claimId) {
public synchronized boolean claimAndRemove(String claimId) {
for (AuctionClaim claim : claims) {
if (claim.id.equals(claimId) && !claim.claimed) {
claim.claimed = true;