mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-03-12 13:19:20 +01:00
2.12.3
This commit is contained in:
parent
494354607f
commit
29a0d2c3be
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.12.3</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -109,8 +109,10 @@ public class AuctionItem implements Serializable {
|
||||
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROL_FOOTER.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
} else {
|
||||
if (Settings.ALLOW_PLAYERS_TO_ACCEPT_BID.getBoolean()) {
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROLS_ACCEPT_BID.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
if (Settings.ALLOW_PLAYERS_TO_ACCEPT_BID.getBoolean() && this.bidStartPrice >= 1 || this.bidIncPrice >= 1) {
|
||||
if (!this.owner.equals(this.highestBidder)) {
|
||||
lore.addAll(Settings.AUCTION_PURCHASE_CONTROLS_ACCEPT_BID.getStringList().stream().map(TextUtils::formatText).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package ca.tweetzy.auctionhouse.exception;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: June 03 2021
|
||||
* Time Created: 11:44 a.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class ItemNotFoundException extends NullPointerException {
|
||||
|
||||
public ItemNotFoundException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
}
|
@ -81,7 +81,7 @@ public class GUIActiveAuctions extends Gui {
|
||||
draw();
|
||||
break;
|
||||
case RIGHT:
|
||||
if (Settings.ALLOW_PLAYERS_TO_ACCEPT_BID.getBoolean() && item.getBidStartPrice() != 0) {
|
||||
if (Settings.ALLOW_PLAYERS_TO_ACCEPT_BID.getBoolean() && item.getBidStartPrice() != 0 && !item.getHighestBidder().equals(e.player.getUniqueId())) {
|
||||
AuctionHouse.newChain().async(() -> AuctionAPI.getInstance().endAuction(item)).sync(this::draw).execute();
|
||||
}
|
||||
break;
|
||||
|
@ -21,10 +21,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -92,8 +89,11 @@ public class GUIAuctionHouse extends Gui {
|
||||
return this.items.stream().sorted(Comparator.comparingInt(AuctionItem::getRemainingTime).reversed()).skip((page - 1) * 45L).limit(45).collect(Collectors.toList());
|
||||
}).asyncLast((data) -> {
|
||||
pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) 45L));
|
||||
drawPaginationButtons();
|
||||
placeItems(data);
|
||||
try {
|
||||
drawPaginationButtons();
|
||||
placeItems(data);
|
||||
} catch (ConcurrentModificationException ignored) {
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
|
||||
import ca.tweetzy.auctionhouse.exception.ItemNotFoundException;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.managers.SoundManager;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
@ -80,54 +81,63 @@ public class GUIConfirmPurchase extends Gui {
|
||||
});
|
||||
setActionForRange(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, ClickType.LEFT, e -> {
|
||||
// Re-select the item to ensure that it's available
|
||||
AuctionItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getKey());
|
||||
preItemChecks(e, located);
|
||||
try {
|
||||
AuctionItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getKey());
|
||||
preItemChecks(e, located);
|
||||
|
||||
// Check economy
|
||||
if (!AuctionHouse.getInstance().getEconomy().has(e.player, this.buyingSpecificQuantity ? this.purchaseQuantity * this.pricePerItem : located.getBasePrice())) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
|
||||
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString(), 1.0F, 1.0F);
|
||||
e.gui.close();
|
||||
return;
|
||||
}
|
||||
if (located == null) {
|
||||
e.gui.close();
|
||||
return;
|
||||
}
|
||||
|
||||
AuctionEndEvent auctionEndEvent = new AuctionEndEvent(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), e.player, this.auctionItem, AuctionSaleType.WITHOUT_BIDDING_SYSTEM, false);
|
||||
Bukkit.getServer().getPluginManager().callEvent(auctionEndEvent);
|
||||
if (auctionEndEvent.isCancelled()) return;
|
||||
// Check economy
|
||||
if (!AuctionHouse.getInstance().getEconomy().has(e.player, this.buyingSpecificQuantity ? this.purchaseQuantity * this.pricePerItem : located.getBasePrice())) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
|
||||
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString(), 1.0F, 1.0F);
|
||||
e.gui.close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean() && e.player.getInventory().firstEmpty() == -1) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.noroom").sendPrefixedMessage(e.player);
|
||||
return;
|
||||
}
|
||||
AuctionEndEvent auctionEndEvent = new AuctionEndEvent(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), e.player, this.auctionItem, AuctionSaleType.WITHOUT_BIDDING_SYSTEM, false);
|
||||
Bukkit.getServer().getPluginManager().callEvent(auctionEndEvent);
|
||||
if (auctionEndEvent.isCancelled()) return;
|
||||
|
||||
if (this.buyingSpecificQuantity) {
|
||||
ItemStack item = AuctionAPI.getInstance().deserializeItem(located.getRawItem());
|
||||
if (!Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean() && e.player.getInventory().firstEmpty() == -1) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.noroom").sendPrefixedMessage(e.player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.buyingSpecificQuantity) {
|
||||
ItemStack item = AuctionAPI.getInstance().deserializeItem(located.getRawItem());
|
||||
|
||||
if (item.getAmount() - this.purchaseQuantity >= 1) {
|
||||
item.setAmount(item.getAmount() - this.purchaseQuantity);
|
||||
located.setRawItem(AuctionAPI.getInstance().serializeItem(item));
|
||||
located.setBasePrice(located.getBasePrice() - this.purchaseQuantity * this.pricePerItem);
|
||||
item.setAmount(this.purchaseQuantity);
|
||||
transferFunds(e.player, this.purchaseQuantity * this.pricePerItem);
|
||||
} else {
|
||||
transferFunds(e.player, located.getBasePrice());
|
||||
AuctionHouse.getInstance().getAuctionItemManager().removeItem(located.getKey());
|
||||
}
|
||||
|
||||
PlayerUtils.giveItem(e.player, item);
|
||||
sendMessages(e, located, true, this.purchaseQuantity * this.pricePerItem);
|
||||
|
||||
if (item.getAmount() - this.purchaseQuantity >= 1) {
|
||||
item.setAmount(item.getAmount() - this.purchaseQuantity);
|
||||
located.setRawItem(AuctionAPI.getInstance().serializeItem(item));
|
||||
located.setBasePrice(located.getBasePrice() - this.purchaseQuantity * this.pricePerItem);
|
||||
item.setAmount(this.purchaseQuantity);
|
||||
transferFunds(e.player, this.purchaseQuantity * this.pricePerItem);
|
||||
} else {
|
||||
transferFunds(e.player, located.getBasePrice());
|
||||
AuctionHouse.getInstance().getAuctionItemManager().removeItem(located.getKey());
|
||||
PlayerUtils.giveItem(e.player, AuctionAPI.getInstance().deserializeItem(located.getRawItem()));
|
||||
sendMessages(e, located, false, 0);
|
||||
}
|
||||
|
||||
PlayerUtils.giveItem(e.player, item);
|
||||
sendMessages(e, located, true, this.purchaseQuantity * this.pricePerItem);
|
||||
|
||||
} else {
|
||||
transferFunds(e.player, located.getBasePrice());
|
||||
AuctionHouse.getInstance().getAuctionItemManager().removeItem(located.getKey());
|
||||
PlayerUtils.giveItem(e.player, AuctionAPI.getInstance().deserializeItem(located.getRawItem()));
|
||||
sendMessages(e, located, false, 0);
|
||||
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getKey()).forEach(player -> {
|
||||
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getKey());
|
||||
player.closeInventory();
|
||||
});
|
||||
} catch (ItemNotFoundException exception) {
|
||||
AuctionHouse.getInstance().getLogger().info("Tried to purchase item that was bought, or does not exist");
|
||||
}
|
||||
|
||||
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getKey()).forEach(player -> {
|
||||
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getKey());
|
||||
player.closeInventory();
|
||||
});
|
||||
});
|
||||
|
||||
if (this.buyingSpecificQuantity) {
|
||||
|
@ -39,7 +39,7 @@ public class AuctionItemManager {
|
||||
}
|
||||
|
||||
public List<AuctionItem> getAuctionItems() {
|
||||
return this.auctionItems;
|
||||
return Collections.unmodifiableList(this.auctionItems);
|
||||
}
|
||||
|
||||
public void loadItems(boolean useDatabase) {
|
||||
|
Loading…
Reference in New Issue
Block a user