mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 02:42:18 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
3e1b4fd692
31 files changed
+381
-148
No files matched your search
@@ -289,7 +289,15 @@ public class AuctionController implements IAuctionHandler {
|
||||
// Global claims are not tied to a single player.
|
||||
claim.playerUUID = null;
|
||||
claim.playerName = "Global";
|
||||
globalClaims.add(claim);
|
||||
synchronized (globalClaims) {
|
||||
// Prevent duplicate claim IDs
|
||||
for (AuctionClaim existing : globalClaims) {
|
||||
if (existing.id.equals(claim.id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
globalClaims.add(claim);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -305,19 +313,23 @@ public class AuctionController implements IAuctionHandler {
|
||||
|
||||
private AuctionClaim getGlobalClaimInternal(String claimId) {
|
||||
if (claimId == null || claimId.isEmpty()) return null;
|
||||
for (AuctionClaim claim : globalClaims) {
|
||||
if (claim != null && !claim.claimed && claimId.equals(claim.id)) {
|
||||
return claim;
|
||||
synchronized (globalClaims) {
|
||||
for (AuctionClaim claim : globalClaims) {
|
||||
if (claim != null && !claim.claimed && claimId.equals(claim.id)) {
|
||||
return claim;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean claimAndRemoveGlobal(String claimId) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) return false;
|
||||
claim.claimed = true;
|
||||
return globalClaims.remove(claim);
|
||||
synchronized (globalClaims) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) return false;
|
||||
claim.claimed = true;
|
||||
return globalClaims.remove(claim);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,15 +370,27 @@ public class AuctionController implements IAuctionHandler {
|
||||
return "This item cannot be listed on the Auction House.";
|
||||
}
|
||||
|
||||
// Validate minimum price
|
||||
// Validate prices
|
||||
if (startingPrice <= 0) {
|
||||
return "Starting price must be positive.";
|
||||
}
|
||||
if (startingPrice < ConfigMarket.MinimumListingPrice) {
|
||||
return "Starting price must be at least " + ConfigMarket.MinimumListingPrice + " " + ConfigMarket.CurrencyName + ".";
|
||||
}
|
||||
if (startingPrice > ConfigMarket.MaxBalance) {
|
||||
return "Starting price exceeds maximum allowed value.";
|
||||
}
|
||||
|
||||
// Validate buyout price if set
|
||||
if (buyoutPrice < 0) {
|
||||
return "Buyout price cannot be negative.";
|
||||
}
|
||||
if (buyoutPrice > 0 && buyoutPrice < startingPrice) {
|
||||
return "Buyout price must be higher than starting price.";
|
||||
}
|
||||
if (buyoutPrice > ConfigMarket.MaxBalance) {
|
||||
return "Buyout price exceeds maximum allowed value.";
|
||||
}
|
||||
|
||||
UUID playerUUID = player.getUniqueID();
|
||||
String playerName = player.getCommandSenderName();
|
||||
@@ -386,7 +410,7 @@ public class AuctionController implements IAuctionHandler {
|
||||
|
||||
PlayerTradeData currency = playerData.tradeData;
|
||||
long fee = ConfigMarket.ListingFee;
|
||||
if (!currency.canAfford(fee)) {
|
||||
if (fee > 0 && !currency.canAfford(fee)) {
|
||||
return "You cannot afford the listing fee (" + fee + " " + ConfigMarket.CurrencyName + ").";
|
||||
}
|
||||
|
||||
@@ -400,7 +424,7 @@ public class AuctionController implements IAuctionHandler {
|
||||
}
|
||||
|
||||
// Deduct fee
|
||||
if (!currency.withdraw(fee)) {
|
||||
if (fee > 0 && !currency.withdraw(fee)) {
|
||||
return "Failed to deduct listing fee.";
|
||||
}
|
||||
|
||||
@@ -435,9 +459,16 @@ public class AuctionController implements IAuctionHandler {
|
||||
return "No item provided.";
|
||||
}
|
||||
|
||||
// Validate prices
|
||||
if (startingPrice <= 0) {
|
||||
return "Starting price must be positive.";
|
||||
}
|
||||
if (startingPrice < ConfigMarket.MinimumListingPrice) {
|
||||
return "Starting price must be at least " + ConfigMarket.MinimumListingPrice + " " + ConfigMarket.CurrencyName + ".";
|
||||
}
|
||||
if (buyoutPrice < 0) {
|
||||
return "Buyout price cannot be negative.";
|
||||
}
|
||||
if (buyoutPrice > 0 && buyoutPrice < startingPrice) {
|
||||
return "Buyout price must be higher than starting price.";
|
||||
}
|
||||
@@ -514,7 +545,13 @@ public class AuctionController implements IAuctionHandler {
|
||||
if (penalty > 0) {
|
||||
PlayerData sellerData = PlayerDataController.Instance.getData(listing.sellerUUID);
|
||||
if (sellerData != null) {
|
||||
sellerData.tradeData.withdraw(penalty);
|
||||
if (!sellerData.tradeData.withdraw(penalty)) {
|
||||
// Withdraw whatever they have if they can't cover the full penalty
|
||||
long available = sellerData.tradeData.getBalance();
|
||||
if (available > 0) {
|
||||
sellerData.tradeData.withdraw(available);
|
||||
}
|
||||
}
|
||||
sellerData.save();
|
||||
}
|
||||
}
|
||||
@@ -551,6 +588,11 @@ public class AuctionController implements IAuctionHandler {
|
||||
return "Auction is disabled.";
|
||||
}
|
||||
|
||||
// Validate bid amount
|
||||
if (bidAmount <= 0) {
|
||||
return "Bid amount must be positive.";
|
||||
}
|
||||
|
||||
UUID playerUUID = player.getUniqueID();
|
||||
String playerName = player.getCommandSenderName();
|
||||
|
||||
@@ -641,14 +683,14 @@ public class AuctionController implements IAuctionHandler {
|
||||
listing.highBidderName = playerName;
|
||||
listing.currentBid = bidAmount;
|
||||
listing.bidCount++;
|
||||
|
||||
// Add to new bidder's active bids
|
||||
addToPlayerBids(playerUUID, listing.id);
|
||||
|
||||
// Snipe protection (must be inside sync to prevent race with endAuction)
|
||||
listing.extendForSnipeProtection(ConfigMarket.SnipeProtectionMinutes);
|
||||
}
|
||||
|
||||
// Add to new bidder's active bids
|
||||
addToPlayerBids(playerUUID, listing.id);
|
||||
|
||||
// Snipe protection
|
||||
listing.extendForSnipeProtection(ConfigMarket.SnipeProtectionMinutes);
|
||||
|
||||
markDirty();
|
||||
|
||||
logAuction(EnumAuctionLogAction.BID, playerName, listing.item.getDisplayName(), bidAmount,
|
||||
@@ -834,26 +876,36 @@ public class AuctionController implements IAuctionHandler {
|
||||
}
|
||||
|
||||
public String claimGlobalItem(String claimId, EntityPlayer player) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) {
|
||||
return "Global claim not found.";
|
||||
}
|
||||
if (!claim.type.isItem()) {
|
||||
return "This global claim is not an item claim.";
|
||||
}
|
||||
if (claim.item == null) {
|
||||
return "Item data is missing.";
|
||||
}
|
||||
String listingId;
|
||||
String itemName;
|
||||
synchronized (globalClaims) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) {
|
||||
return "Global claim not found.";
|
||||
}
|
||||
if (!claim.type.isItem()) {
|
||||
return "This global claim is not an item claim.";
|
||||
}
|
||||
if (claim.item == null) {
|
||||
return "Item data is missing.";
|
||||
}
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(claim.item.copy())) {
|
||||
return "Your inventory is full.";
|
||||
}
|
||||
// Check inventory space before adding (addItemStackToInventory mutates even on partial add)
|
||||
if (!canFitInInventory(player, claim.item)) {
|
||||
return "Not enough inventory space to claim this item.";
|
||||
}
|
||||
|
||||
claimAndRemoveGlobal(claim.id);
|
||||
cleanupListingIfComplete(claim.listingId);
|
||||
// Add to inventory (safe - we verified space above)
|
||||
player.inventory.addItemStackToInventory(claim.item.copy());
|
||||
|
||||
listingId = claim.listingId;
|
||||
itemName = claim.item.getDisplayName();
|
||||
claimAndRemoveGlobal(claim.id);
|
||||
}
|
||||
cleanupListingIfComplete(listingId);
|
||||
markDirty();
|
||||
|
||||
logAuction(EnumAuctionLogAction.CLAIMED, player.getCommandSenderName(), claim.item.getDisplayName(), 0,
|
||||
logAuction(EnumAuctionLogAction.CLAIMED, player.getCommandSenderName(), itemName, 0,
|
||||
"Global item claim");
|
||||
return null;
|
||||
}
|
||||
@@ -862,19 +914,25 @@ public class AuctionController implements IAuctionHandler {
|
||||
* Global currency claims are acknowledged/cleared and do not alter player balances.
|
||||
*/
|
||||
public String claimGlobalCurrency(String claimId, EntityPlayer player) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) {
|
||||
return "Global claim not found.";
|
||||
}
|
||||
if (!claim.type.isCurrency()) {
|
||||
return "This global claim is not a currency claim.";
|
||||
}
|
||||
String listingId;
|
||||
long currency;
|
||||
synchronized (globalClaims) {
|
||||
AuctionClaim claim = getGlobalClaimInternal(claimId);
|
||||
if (claim == null) {
|
||||
return "Global claim not found.";
|
||||
}
|
||||
if (!claim.type.isCurrency()) {
|
||||
return "This global claim is not a currency claim.";
|
||||
}
|
||||
|
||||
claimAndRemoveGlobal(claim.id);
|
||||
cleanupListingIfComplete(claim.listingId);
|
||||
listingId = claim.listingId;
|
||||
currency = claim.currency;
|
||||
claimAndRemoveGlobal(claim.id);
|
||||
}
|
||||
cleanupListingIfComplete(listingId);
|
||||
markDirty();
|
||||
|
||||
logAuction(EnumAuctionLogAction.CLAIMED, player.getCommandSenderName(), ConfigMarket.CurrencyName, claim.currency,
|
||||
logAuction(EnumAuctionLogAction.CLAIMED, player.getCommandSenderName(), ConfigMarket.CurrencyName, currency,
|
||||
"Global currency claim acknowledged (no balance change)");
|
||||
return null;
|
||||
}
|
||||
@@ -910,11 +968,14 @@ public class AuctionController implements IAuctionHandler {
|
||||
return "Claim was prevented.";
|
||||
}
|
||||
|
||||
// Check inventory space
|
||||
if (!player.inventory.addItemStackToInventory(claim.item.copy())) {
|
||||
return "Your inventory is full.";
|
||||
// Check inventory space before adding (addItemStackToInventory mutates even on partial add)
|
||||
if (!canFitInInventory(player, claim.item)) {
|
||||
return "Not enough inventory space to claim this item.";
|
||||
}
|
||||
|
||||
// Add to inventory (safe - we verified space above)
|
||||
player.inventory.addItemStackToInventory(claim.item.copy());
|
||||
|
||||
// Remove claim from player's auction data
|
||||
playerData.tradeData.claimAndRemove(claimId);
|
||||
playerData.updateClient = true;
|
||||
@@ -973,6 +1034,34 @@ public class AuctionController implements IAuctionHandler {
|
||||
return null; // Success
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player's inventory can fit the entire ItemStack without partial adds.
|
||||
* Unlike addItemStackToInventory, this does NOT mutate the inventory.
|
||||
*/
|
||||
private boolean canFitInInventory(EntityPlayer player, ItemStack stack) {
|
||||
int remaining = stack.stackSize;
|
||||
int maxStack = stack.getMaxStackSize();
|
||||
ItemStack[] mainInventory = player.inventory.mainInventory;
|
||||
|
||||
for (int i = 0; i < mainInventory.length; i++) {
|
||||
if (remaining <= 0) return true;
|
||||
|
||||
ItemStack slot = mainInventory[i];
|
||||
if (slot == null) {
|
||||
remaining -= Math.min(remaining, maxStack);
|
||||
} else if (slot.getItem() == stack.getItem()
|
||||
&& slot.getItemDamage() == stack.getItemDamage()
|
||||
&& ItemStack.areItemStackTagsEqual(slot, stack)) {
|
||||
int spaceInSlot = maxStack - slot.stackSize;
|
||||
if (spaceInSlot > 0) {
|
||||
remaining -= Math.min(remaining, spaceInSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return remaining <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up a listing if it's ended and no longer needed.
|
||||
* Now just removes ended listings after some delay since claims are in PlayerData.
|
||||
@@ -1019,6 +1108,7 @@ public class AuctionController implements IAuctionHandler {
|
||||
|
||||
for (AuctionListing listing : listings.values()) {
|
||||
if (listing.status != EnumAuctionStatus.ACTIVE) continue;
|
||||
if (listing.isExpired()) continue;
|
||||
|
||||
// Apply search filter (searches item name AND seller name)
|
||||
if (filter.hasSearchText()) {
|
||||
@@ -1069,6 +1159,7 @@ public class AuctionController implements IAuctionHandler {
|
||||
int count = 0;
|
||||
for (AuctionListing listing : listings.values()) {
|
||||
if (listing.status != EnumAuctionStatus.ACTIVE) continue;
|
||||
if (listing.isExpired()) continue;
|
||||
if (filter.hasSearchText()) {
|
||||
String itemName = listing.item != null ? listing.item.getDisplayName() : "";
|
||||
String sellerName = listing.sellerName != null ? listing.sellerName : "";
|
||||
@@ -1755,20 +1846,12 @@ public class AuctionController implements IAuctionHandler {
|
||||
|
||||
String itemName = listing.item != null ? listing.item.getDisplayName() : "Unknown Item";
|
||||
|
||||
// Return active highest bid.
|
||||
// Return active highest bid - always refund to the actual bidder
|
||||
if (listing.hasBids() && listing.highBidderUUID != null) {
|
||||
AuctionClaim refundClaim;
|
||||
if (cancelCompletely) {
|
||||
refundClaim = AuctionClaim.createRefundClaim(
|
||||
null, "Global", listing.id, listing.currentBid, itemName,
|
||||
listing.highBidderName, null);
|
||||
addGlobalClaim(refundClaim);
|
||||
} else {
|
||||
refundClaim = AuctionClaim.createRefundClaim(
|
||||
listing.highBidderUUID, listing.highBidderName, listing.id, listing.currentBid, itemName,
|
||||
listing.sellerName, null);
|
||||
addClaimToPlayer(listing.highBidderUUID, refundClaim);
|
||||
}
|
||||
AuctionClaim refundClaim = AuctionClaim.createRefundClaim(
|
||||
listing.highBidderUUID, listing.highBidderName, listing.id, listing.currentBid, itemName,
|
||||
listing.sellerName, null);
|
||||
addClaimToPlayer(listing.highBidderUUID, refundClaim);
|
||||
removeFromPlayerBids(listing.highBidderUUID, listing.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.handler.ILinkedItemHandler;
|
||||
import noppes.npcs.api.handler.data.ILinkedItem;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
@@ -21,7 +22,7 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class LinkedItemController {
|
||||
public class LinkedItemController implements ILinkedItemHandler {
|
||||
private static LinkedItemController Instance;
|
||||
private int lastUsedID = 0;
|
||||
|
||||
@@ -40,25 +41,28 @@ public class LinkedItemController {
|
||||
return Instance;
|
||||
}
|
||||
|
||||
public LinkedItem createItem(String name) {
|
||||
@Override
|
||||
public ILinkedItem createItem(String name) {
|
||||
return new LinkedItem(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack createItemStack(int id) {
|
||||
LinkedItem linkedItem = this.get(id);
|
||||
LinkedItem linkedItem = (LinkedItem) this.get(id);
|
||||
if (linkedItem != null) {
|
||||
return linkedItem.createStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void add(LinkedItem linkedItem) {
|
||||
@Override
|
||||
public void add(ILinkedItem linkedItem) {
|
||||
if (linkedItem != null) {
|
||||
String name = linkedItem.getName();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
int linkedItemId = linkedItem.getId();
|
||||
int id = this.linkedItems.containsKey(linkedItemId) ? linkedItemId : this.getUnusedId();
|
||||
this.linkedItems.put(id, linkedItem);
|
||||
this.linkedItems.put(id, (LinkedItem) linkedItem);
|
||||
linkedItem.setId(id);
|
||||
this.addScript(id);
|
||||
}
|
||||
@@ -69,6 +73,7 @@ public class LinkedItemController {
|
||||
this.linkedItemsScripts.put(id, new LinkedItemScript());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedItem remove(int id) {
|
||||
this.removeScript(id);
|
||||
return this.linkedItems.remove(id);
|
||||
@@ -78,16 +83,19 @@ public class LinkedItemController {
|
||||
this.linkedItemsScripts.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedItem get(int id) {
|
||||
return this.linkedItems.get(id);
|
||||
return (LinkedItem) this.linkedItems.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int id) {
|
||||
return this.linkedItems.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean contains(LinkedItem linkedItem) {
|
||||
return this.linkedItems.containsValue(linkedItem);
|
||||
@Override
|
||||
public boolean contains(ILinkedItem linkedItem) {
|
||||
return this.linkedItems.containsValue((LinkedItem) linkedItem);
|
||||
}
|
||||
|
||||
public IScriptHandler getScriptHandler(int id) {
|
||||
@@ -219,7 +227,7 @@ public class LinkedItemController {
|
||||
}
|
||||
|
||||
public void delete(int id) {
|
||||
LinkedItem linkedItem = get(id);
|
||||
LinkedItem linkedItem = (LinkedItem) get(id);
|
||||
if (linkedItem != null) {
|
||||
LinkedItem foundItem = remove(id);
|
||||
if (foundItem != null && foundItem.name != null) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user