This commit is contained in:
Kiran Hart 2021-08-19 14:19:04 -04:00
parent 7ae25a5ea3
commit 56ed206425
10 changed files with 127 additions and 5 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/src/test/
.idea
AuctionHouse.iml
/src/main/test/

View File

@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.26.1</version>
<version>2.27.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -218,11 +218,18 @@ public class AuctionHouse extends TweetyPlugin {
getLogger().severe("You are not running Java 16, Auction House will be updated to use Java 16 in the coming months. If you do not update, you will not be able to use Auction House.");
}
if (USER.equals("%%__USER__%%")) {
final String uIDPartOne = "%%__US";
final String uIDPartTwo = "ER__%%";
if (USER.contains(uIDPartOne) && USER.contains(uIDPartTwo)) {
getLogger().severe("Could not detect user ID, are you running a cracked / self-compiled copy of auction house?");
} else {
getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
getConsole().sendMessage(TextUtils.formatText(""));
getConsole().sendMessage(TextUtils.formatText("&aThank you for purchasing Auction House, it means a lot"));
getConsole().sendMessage(TextUtils.formatText("&7 - Kiran Hart"));
getConsole().sendMessage(TextUtils.formatText(""));
getConsole().sendMessage(TextUtils.formatText("&e&m--------------------------------------------------------"));
}
}, 1L);
}

View File

@ -23,11 +23,15 @@ import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BundleMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.io.BukkitObjectInputStream;
@ -498,6 +502,10 @@ public class AuctionAPI {
put("%item_name%", getItemName(baseItem));
}});
ItemMeta meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
item.setItemMeta(meta);
int total = items.length;
item = NBTEditor.set(item, total, "AuctionBundleItem");
item = NBTEditor.set(item, UUID.randomUUID().toString(), "AuctionBundleItemUUID-" + UUID.randomUUID().toString());

View File

@ -96,7 +96,9 @@ public class AuctionedItem {
if (this.isBidItem) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : AuctionAPI.getInstance().formatNumber(this.currentPrice))).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncrementPrice) : AuctionAPI.getInstance().formatNumber(this.bidIncrementPrice))).collect(Collectors.toList())));
if (!Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_BID_INCREMENT.getStringList().stream().map(s -> s.replace("%bidincrement%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.bidIncrementPrice) : AuctionAPI.getInstance().formatNumber(this.bidIncrementPrice))).collect(Collectors.toList())));
}
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HIGHEST_BIDDER.getStringList().stream().map(s -> s.replace("%highestbidder%", this.highestBidder.equals(this.owner) ? AuctionHouse.getInstance().getLocale().getMessage("auction.nobids").getMessage() : this.highestBidderName)).collect(Collectors.toList())));
}

View File

@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.*;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmPurchase;
import ca.tweetzy.auctionhouse.guis.filter.GUIFilterSelection;
import ca.tweetzy.auctionhouse.guis.transaction.GUITransactionList;
@ -15,11 +16,14 @@ import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.input.PlayerChatInput;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import ca.tweetzy.core.utils.nms.NBTEditor;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.ShulkerBox;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@ -197,6 +201,78 @@ public class GUIAuctionHouse extends Gui {
}
cleanup();
if (Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
e.gui.exit();
PlayerChatInput.PlayerChatInputBuilder<Double> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
builder.isValidInput((p, str) -> NumberUtils.isDouble(str) && Double.parseDouble(str) >= auctionItem.getBidIncrementPrice());
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter bid amount").getMessage()));
builder.toCancel("cancel");
builder.onCancel(p -> e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)));
builder.setValue((p, value) -> Double.parseDouble(value));
builder.onFinish((p, value) -> {
if (value > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(e.player);
return;
}
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, auctionItem.getCurrentPrice() + value)) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
if (Settings.ASK_FOR_BID_CONFIRMATION.getBoolean()) {
e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem, value));
return;
}
ItemStack itemStack = auctionItem.getItem();
OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
OfflinePlayer owner = Bukkit.getOfflinePlayer(auctionItem.getOwner());
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setHighestBidderName(e.player.getName());
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + value);
if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
auctionItem.setBasePrice(auctionItem.getCurrentPrice());
}
if (Settings.INCREASE_TIME_ON_BID.getBoolean()) {
auctionItem.setExpiresAt(auctionItem.getExpiresAt() + 1000L * Settings.TIME_TO_INCREASE_BY_ON_BID.getInt());
}
if (oldBidder.isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.outbid")
.processPlaceholder("player", e.player.getName())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(oldBidder.getPlayer());
}
if (owner.isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid")
.processPlaceholder("player", e.player.getName())
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(owner.getPlayer());
}
if (Settings.BROADCAST_AUCTION_BID.getBoolean()) {
Bukkit.getOnlinePlayers().forEach(player -> AuctionHouse.getInstance().getLocale().getMessage("auction.broadcast.bid")
.processPlaceholder("player", e.player.getName())
.processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
.sendPrefixedMessage(player));
}
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
});
PlayerChatInput<Double> input = builder.build();
input.start();
return;
}
e.manager.showGUI(e.player, new GUIBid(this.auctionPlayer, auctionItem));
}

View File

@ -7,6 +7,7 @@ import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmBid;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.input.PlayerChatInput;
@ -62,6 +63,11 @@ public class GUIBid extends Gui {
builder.onCancel(p -> e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)));
builder.setValue((p, value) -> Double.parseDouble(value));
builder.onFinish((p, value) -> {
if (value > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(e.player);
return;
}
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, auctionItem.getCurrentPrice() + value)) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;

View File

@ -10,6 +10,7 @@ import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.event.inventory.ClickType;
import java.util.Comparator;
import java.util.List;
@ -27,6 +28,7 @@ public class GUIExpiredItems extends Gui {
final AuctionPlayer auctionPlayer;
private List<AuctionedItem> items;
private Long lastClicked = null;
public GUIExpiredItems(AuctionPlayer auctionPlayer) {
this.auctionPlayer = auctionPlayer;
@ -36,6 +38,11 @@ public class GUIExpiredItems extends Gui {
draw();
}
public GUIExpiredItems(AuctionPlayer auctionPlayer, Long lastClicked) {
this(auctionPlayer);
this.lastClicked = lastClicked;
}
private void draw() {
reset();
@ -65,11 +72,19 @@ public class GUIExpiredItems extends Gui {
int slot = 0;
for (AuctionedItem auctionItem : data) {
setButton(slot++, auctionItem.getItem(), e -> {
setButton(slot++, auctionItem.getItem(), ClickType.LEFT, e -> {
if (!Settings.ALLOW_INDIVIDUAL_ITEM_CLAIM.getBoolean()) return;
if (this.lastClicked == null) {
this.lastClicked = System.currentTimeMillis() + Settings.CLAIM_MS_DELAY.getInt();
} else if (this.lastClicked > System.currentTimeMillis()) {
return;
} else {
this.lastClicked = System.currentTimeMillis() + Settings.CLAIM_MS_DELAY.getInt();
}
PlayerUtils.giveItem(e.player, auctionItem.getItem());
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(auctionItem);
e.manager.showGUI(e.player, new GUIExpiredItems(this.auctionPlayer));
e.manager.showGUI(e.player, new GUIExpiredItems(this.auctionPlayer, this.lastClicked));
});
}

View File

@ -184,6 +184,10 @@ public class GUISellItem extends Gui {
setButton(3, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> {
AuctionHouse.getInstance().getAuctionPlayerManager().removeFromUsingSellGUI(e.player.getUniqueId());
setAllowClose(true);
if (Settings.SELL_MENU_CLOSE_SENDS_TO_LISTING.getBoolean()) {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
return;
}
e.gui.close();
});

View File

@ -44,6 +44,7 @@ public class Settings {
public static final ConfigSetting TIME_TO_INCREASE_BY_ON_BID = new ConfigSetting(config, "auction setting.time to increase by on the bid", 20, "How many seconds should be added to the remaining time?");
public static final ConfigSetting TICK_UPDATE_TIME = new ConfigSetting(config, "auction setting.tick auctions every", 1, "How many seconds should pass before the plugin updates all the times on items?");
public static final ConfigSetting CLAIM_MS_DELAY = new ConfigSetting(config, "auction setting.item claim delay", 100, "How many ms should a player wait before being allowed to claim an item?, Ideally you don't wanna change this. It's meant to prevent auto clicker dupe claims");
public static final ConfigSetting TICK_UPDATE_GUI_TIME = new ConfigSetting(config, "auction setting.refresh gui every", 10, "How many seconds should pass before the auction gui auto refreshes?");
public static final ConfigSetting RECORD_TRANSACTIONS = new ConfigSetting(config, "auction setting.record transactions", true, "Should every transaction be recorded (everything an auction is won or an item is bought)");
@ -67,6 +68,7 @@ public class Settings {
public static final ConfigSetting ALLOW_USAGE_OF_SELL_GUI = new ConfigSetting(config, "auction setting.allow usage of sell gui", true, "Should the sell menu be enabled?");
public static final ConfigSetting FORCE_AUCTION_USAGE = new ConfigSetting(config, "auction setting.force auction usage", false, "If enabled, all items sold on the auction house must be an auction (biddable) items");
public static final ConfigSetting ALLOW_INDIVIDUAL_ITEM_CLAIM = new ConfigSetting(config, "auction setting.allow individual item claim", true, "If enabled, you will be able to click individual items from the expiration menu to claim them back. Otherwise you will have to use the claim all button");
public static final ConfigSetting FORCE_CUSTOM_BID_AMOUNT = new ConfigSetting(config, "auction setting.force custom bid amount", false, "If enabled, the bid increment line on auction items will be hidden, bid increment values will be ignored, and when you go to bid on an item, it will ask you to enter a custom amount.");
public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on bid items", true, "Should Auction House ask the user if they want to cancel the item?");
public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_NON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on non bid items", false, "Should Auction House ask the user if they want to cancel the item?");
@ -80,6 +82,7 @@ public class Settings {
public static final ConfigSetting USE_SEPARATE_FILTER_MENU = new ConfigSetting(config, "auction setting.use separate filter menu", false, "If true, rather than using a single filter item inside the auction menu", "it will open an entirely new menu to select the filter");
public static final ConfigSetting SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM = new ConfigSetting(config, "auction setting.require user to hold item when using sell menu", false, "If enabled, when running just /ah sell, the user will need to hold the item in their hand, otherwise they just add it in the gui.");
public static final ConfigSetting OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST = new ConfigSetting(config, "auction setting.open main auction house after listing using menu", true, "Should the main auction house be opened after the user lists an item using the sell menu?");
public static final ConfigSetting SELL_MENU_CLOSE_SENDS_TO_LISTING = new ConfigSetting(config, "auction setting.sell menu close sends to listings", true, "If true, when the player clicks the close button within the sell menu, it will send them to the main auction house");
public static final ConfigSetting TAX_ENABLED = new ConfigSetting(config, "auction setting.tax.enabled", false, "Should auction house use it's tax system?");
public static final ConfigSetting TAX_CHARGE_LISTING_FEE = new ConfigSetting(config, "auction setting.tax.charge listing fee", true, "Should auction house charge players to list an item?");