Complete request system

Took 1 hour 5 minutes
This commit is contained in:
Kiran Hart 2023-11-17 20:13:25 -05:00
parent b4403e905c
commit bb46521cda
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
19 changed files with 428 additions and 862 deletions

View File

@ -229,7 +229,8 @@ public class AuctionHouse extends TweetyPlugin {
new _16_StatisticVersionTwoMigration(),
new _17_PaymentsMigration(),
new _18_PaymentsItemMigration(),
new _19_ServerAuctionMigration()
new _19_ServerAuctionMigration(),
new _20_AuctionRequestsMigration()
);
dataMigrationManager.runMigrations();
@ -290,7 +291,8 @@ public class AuctionHouse extends TweetyPlugin {
new CommandMinPrice(),
new CommandStats(),
new CommandPayments(),
new CommandBids()
new CommandBids(),
new CommandRequest()
);
// Placeholder API

View File

@ -71,6 +71,7 @@ public class AuctionedItem {
private boolean infinite = false;
private boolean allowPartialBuy = false;
private boolean serverItem = false;
private boolean isRequest = false;
public AuctionedItem() {
}
@ -106,6 +107,7 @@ public class AuctionedItem {
this.expired = expired;
this.expiresAt = expiresAt;
this.serverItem = false;
this.isRequest = false;
}
public ItemStack getBidStack() {
@ -148,6 +150,45 @@ public class AuctionedItem {
return itemStack;
}
public ItemStack getDisplayRequestStack(AuctionStackType type) {
ItemStack itemStack = this.item.clone();
itemStack.setAmount(Math.max(this.item.getAmount(), 1));
ItemMeta meta = itemStack.hasItemMeta() ? itemStack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(itemStack.getType());
List<String> lore = new ArrayList<>();
if (meta != null && meta.getLore() != null)
lore.addAll(meta.getLore());
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HEADER.getStringList()));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUESTER.getStringList().stream().map(s -> s.replace("%requester%", this.ownerName)).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_REQUEST_PRICE.getStringList().stream().map(s -> s.replace("%request_price%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.basePrice) : AuctionAPI.getInstance().formatNumber(this.basePrice))).collect(Collectors.toList())));
long[] times = AuctionAPI.getInstance().getRemainingTimeValues((this.expiresAt - System.currentTimeMillis()) / 1000);
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_TIME_LEFT.getStringList().stream().map(s -> s
.replace("%remaining_days%", String.valueOf(times[0]))
.replace("%remaining_hours%", String.valueOf(times[1]))
.replace("%remaining_minutes%", String.valueOf(times[2]))
.replace("%remaining_seconds%", String.valueOf(times[3]))
.replace("%remaining_total_hours%", String.valueOf(((this.expiresAt - System.currentTimeMillis()) / 1000) / 3600))
).collect(Collectors.toList())));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_PURCHASE_CONTROL_HEADER.getStringList()));
if (type == AuctionStackType.ACTIVE_AUCTIONS_LIST)
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_PURCHASE_CONTROLS_CANCEL_REQUEST.getStringList()));
if (type == AuctionStackType.MAIN_AUCTION_HOUSE)
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_PURCHASE_CONTROLS_FULFILL_REQUEST.getStringList()));
lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_PURCHASE_CONTROL_FOOTER.getStringList()));
meta.setLore(lore);
itemStack.setItemMeta(meta);
return itemStack;
}
public ItemStack getDisplayStack(AuctionStackType type) {
ItemStack itemStack = this.item.clone();
itemStack.setAmount(Math.max(this.item.getAmount(), 1));

View File

@ -0,0 +1,170 @@
/*
* Auction House
* Copyright 2018-2022 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.commands;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.helpers.AuctionCreator;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.TextUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.UUID;
/**
* The current file has been created by Kiran Hart
* Date Created: March 15 2021
* Time Created: 4:32 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class CommandRequest extends AbstractCommand {
public CommandRequest() {
super(CommandType.PLAYER_ONLY, "request");
}
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
final Player player = (Player) sender;
final AuctionHouse instance = AuctionHouse.getInstance();
if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE;
if (args.length < 1) return ReturnType.FAILURE;
// check if price is even a number
if (!NumberUtils.isDouble(args[0])) {
instance.getLocale().getMessage("general.notanumber").processPlaceholder("value", args[0]).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) {
instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender());
instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player));
}
final AuctionPlayer auctionPlayer = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId());
// grab held item & check valid
final ItemStack originalItem = PlayerHelper.getHeldItem(player).clone();
if (originalItem.getType() == XMaterial.AIR.parseMaterial()) {
instance.getLocale().getMessage("general.air").sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
// Check for block items
if (!AuctionAPI.getInstance().meetsListingRequirements(player, originalItem)) return ReturnType.FAILURE;
// check if at limit
if (auctionPlayer.isAtItemLimit(player)) {
instance.getLocale().getMessage("general.requestlimit").sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
// get the max allowed time for this player.
final int allowedTime = auctionPlayer.getAllowedSellTime(AuctionSaleType.WITHOUT_BIDDING_SYSTEM);
// Check list delay
if (!auctionPlayer.canListItem()) {
return ReturnType.FAILURE;
}
// check min/max prices
final double price = Double.parseDouble(args[0]);
if (price < Settings.MIN_AUCTION_PRICE.getDouble()) {
instance.getLocale().getMessage("pricing.minbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
if (price > Settings.MAX_AUCTION_PRICE.getDouble()) {
instance.getLocale().getMessage("pricing.maxbaseprice").processPlaceholder("price", Settings.MIN_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
AuctionedItem auctionedItem = new AuctionedItem();
auctionedItem.setId(UUID.randomUUID());
auctionedItem.setOwner(player.getUniqueId());
auctionedItem.setHighestBidder(player.getUniqueId());
auctionedItem.setOwnerName(player.getName());
auctionedItem.setHighestBidderName(player.getName());
auctionedItem.setBasePrice(price);
auctionedItem.setItem(originalItem.clone());
auctionedItem.setCategory(MaterialCategorizer.getMaterialCategory(originalItem));
auctionedItem.setExpiresAt(System.currentTimeMillis() + 1000L * allowedTime);
auctionedItem.setBidItem(false);
auctionedItem.setServerItem(false);
auctionedItem.setExpired(false);
auctionedItem.setListedWorld(player.getWorld().getName());
auctionedItem.setInfinite(false);
auctionedItem.setAllowPartialBuy(false);
auctionedItem.setRequest(true);
AuctionHouse.getInstance().getAuctionPlayerManager().addToSellProcess(player);
if (auctionPlayer.getPlayer() == null || !auctionPlayer.getPlayer().isOnline()) {
return ReturnType.FAILURE;
}
AuctionCreator.create(auctionPlayer, auctionedItem, (auction, listingResult) -> {
AuctionHouse.getInstance().getAuctionPlayerManager().processSell(player);
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance());
instance.getGuiManager().showGUI(player, new GUIAuctionHouse(auctionPlayer));
} else
AuctionHouse.newChain().sync(player::closeInventory).execute();
});
return ReturnType.SUCCESS;
}
@Override
public String getPermissionNode() {
return "auctionhouse.cmd.request";
}
@Override
public String getSyntax() {
return AuctionHouse.getInstance().getLocale().getMessage("commands.syntax.request").getMessage();
}
@Override
public String getDescription() {
return AuctionHouse.getInstance().getLocale().getMessage("commands.description.request").getMessage();
}
@Override
protected List<String> onTab(CommandSender sender, String... args) {
return null;
}
}

View File

@ -146,6 +146,7 @@ public final class CommandSell extends AbstractCommand {
boolean isStackPrice = false;
boolean partialBuy = false;
boolean serverAuction = false;
boolean isRequest = false;
List<String> timeSets = Arrays.asList(
"second",

View File

@ -1,59 +0,0 @@
/*
* Auction House
* Copyright 2023 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.commands.v3;
import ca.tweetzy.flight.command.AllowedExecutor;
import ca.tweetzy.flight.command.Command;
import ca.tweetzy.flight.command.ReturnType;
import org.bukkit.command.CommandSender;
import java.util.List;
public final class AuctionHouseCommand extends Command {
public AuctionHouseCommand() {
super(AllowedExecutor.BOTH, "a3");
}
@Override
protected ReturnType execute(CommandSender sender, String... args) {
return ReturnType.SUCCESS;
}
@Override
protected List<String> tab(CommandSender sender, String... args) {
return null;
}
@Override
public String getPermissionNode() {
return "auctionhouse.v3.command";
}
@Override
public String getSyntax() {
return null;
}
@Override
public String getDescription() {
return null;
}
}

View File

@ -324,7 +324,7 @@ public class DataManager extends DataManagerAbstract {
public void insertAuction(AuctionedItem item, Callback<AuctionedItem> callback) {
this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite, allow_partial_buys, server_auction) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite, allow_partial_buys, server_auction, is_request) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
final AuctionAPI api = AuctionAPI.getInstance();
PreparedStatement fetch = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "auctions WHERE id = ?");
@ -350,6 +350,7 @@ public class DataManager extends DataManagerAbstract {
statement.setBoolean(19, item.isInfinite());
statement.setBoolean(20, item.isAllowPartialBuy());
statement.setBoolean(21, item.isServerItem());
statement.setBoolean(22, item.isRequest());
statement.executeUpdate();
@ -734,6 +735,7 @@ public class DataManager extends DataManagerAbstract {
auctionItem.setInfinite(hasColumn(resultSet, "infinite") && resultSet.getBoolean("infinite"));
auctionItem.setAllowPartialBuy(hasColumn(resultSet, "allow_partial_buys") && resultSet.getBoolean("allow_partial_buys"));
auctionItem.setServerItem(resultSet.getBoolean("server_auction"));
auctionItem.setRequest(resultSet.getBoolean("is_request"));
return auctionItem;
}

View File

@ -0,0 +1,46 @@
/*
* Auction House
* Copyright 2018-2022 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.database.migrations;
import ca.tweetzy.core.database.DataMigration;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
/**
* The current file has been created by Kiran Hart
* Date Created: August 12 2021
* Time Created: 11:58 a.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class _20_AuctionRequestsMigration extends DataMigration {
public _20_AuctionRequestsMigration() {
super(20);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD is_request BOOLEAN NOT NULL DEFAULT 0");
}
}
}

View File

@ -103,6 +103,15 @@ public abstract class AbstractPlaceholderGui extends Gui {
return ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_CONFIRM_BUY_NO_ITEM.getString(), Settings.GUI_CONFIRM_BUY_NO_NAME.getString(), Settings.GUI_CONFIRM_BUY_NO_LORE.getStringList(), null);
}
protected ItemStack getConfirmRequestYesItem() {
return ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_CONFIRM_REQUEST_YES_ITEM.getString(), Settings.GUI_CONFIRM_REQUEST_YES_NAME.getString(), Settings.GUI_CONFIRM_REQUEST_YES_LORE.getStringList(), null);
}
protected ItemStack getConfirmRequestNoItem() {
return ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_CONFIRM_REQUEST_NO_ITEM.getString(), Settings.GUI_CONFIRM_REQUEST_NO_NAME.getString(), Settings.GUI_CONFIRM_REQUEST_NO_LORE.getStringList(), null);
}
protected ItemStack getConfirmListingYesItem() {
return ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_CONFIRM_LISTING_YES_ITEM.getString(), Settings.GUI_CONFIRM_LISTING_YES_NAME.getString(), Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList(), null);
}

View File

@ -89,9 +89,16 @@ public class GUIActiveAuctions extends AbstractPlaceholderGui {
int slot = 0;
for (AuctionedItem item : data) {
setButton(slot++, item.getDisplayStack(AuctionStackType.ACTIVE_AUCTIONS_LIST), e -> {
setButton(slot++, item.isRequest() ? item.getDisplayRequestStack(AuctionStackType.ACTIVE_AUCTIONS_LIST) : item.getDisplayStack(AuctionStackType.ACTIVE_AUCTIONS_LIST), e -> {
switch (e.clickType) {
case LEFT:
if (item.isRequest()) {
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(item);
cleanup();
e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer));
return;
}
if (Settings.SELLERS_MUST_WAIT_FOR_TIME_LIMIT_AFTER_BID.getBoolean() && item.containsValidBid()) {
AuctionHouse.getInstance().getLocale().getMessage("general.cannot cancel item with bid").sendPrefixedMessage(e.player);
return;

View File

@ -459,7 +459,7 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
int slot = 0;
for (AuctionedItem auctionItem : data) {
setButton(slot++, auctionItem.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE), e -> {
setButton(slot++, auctionItem.isRequest() ? auctionItem.getDisplayRequestStack(AuctionStackType.MAIN_AUCTION_HOUSE) : auctionItem.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE), e -> {
// Non Type specific actions
if (e.clickType == ClickType.valueOf(Settings.CLICKS_INSPECT_CONTAINER.getString().toUpperCase())) {
handleContainerInspect(e);
@ -474,6 +474,14 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
// Non Biddable Items
if (!auctionItem.isBidItem()) {
if (e.clickType == ClickType.valueOf(Settings.CLICKS_NON_BID_ITEM_PURCHASE.getString().toUpperCase())) {
// special case for request
if (auctionItem.isRequest()) {
cleanup();
e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, false));
AuctionHouse.getInstance().getTransactionManager().addPrePurchase(e.player, auctionItem.getId());
return;
}
handleNonBidItem(auctionItem, e, false);
return;
}

View File

@ -1,762 +0,0 @@
/*
* Auction House
* Copyright 2018-2022 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.guis.abstraction.AuctionUpdatingPagedGUI;
import ca.tweetzy.auctionhouse.impl.listing.AuctionItem;
import ca.tweetzy.auctionhouse.settings.v3.Settings;
import ca.tweetzy.flight.gui.Gui;
import ca.tweetzy.flight.gui.events.GuiClickEvent;
import ca.tweetzy.flight.utils.Common;
import lombok.NonNull;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
/**
* The current file has been created by Kiran Hart
* Date Created: March 14 2021
* Time Created: 6:34 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class GUIAuctionHouseV3 extends AuctionUpdatingPagedGUI<AuctionItem> {
private final String searchKeywords;
public GUIAuctionHouseV3(Gui parent, @NonNull Player player, final String searchKeywords) {
super(parent, player, Common.colorize("<GRADIENT:FE8295>&lAuction House</GRADIENT:FFAD96>"), Settings.GUI_MAIN_ROWS.getInt() < 2 ? 2 : Math.min(Settings.GUI_MAIN_ROWS.getInt(), 6), Settings.TIMER_AUTO_REFRESH_MAIN_AUCTION.getInt(), new ArrayList<>());
this.searchKeywords = searchKeywords;
// first render draw
draw();
// start the update task
if (Settings.TIMER_AUTO_REFRESH_MAIN_AUCTION.getInt() != 0)
startTask();
applyClose();
}
public GUIAuctionHouseV3(Gui parent, @NonNull Player player) {
this(parent, player, null);
}
@Override
protected ItemStack makeDisplayItem(AuctionItem object) {
return null;
}
@Override
protected void onClick(AuctionItem object, GuiClickEvent clickEvent) {
}
// public GUIAuctionHouseV3(AuctionPlayer auctionPlayer) {
// super(auctionPlayer);
// this.auctionPlayer = auctionPlayer;
//
// if (!Bukkit.getOfflinePlayer(this.auctionPlayer.getUuid()).isOnline())
// return;
//
// setTitle(TextUtils.formatText(Settings.GUI_AUCTION_HOUSE_TITLE.getString()));
// setRows(6);
// setAcceptsItems(false);
// setAllowShiftClick(false);
// setNavigateSound(XSound.matchXSound(Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString()).orElse(XSound.ENTITY_BAT_TAKEOFF));
// draw();
//
// setOnOpen(open -> {
// if (AuctionHouse.getInstance().getAuctionBanManager().checkAndHandleBan(open.player)) {
// open.gui.exit();
// return;
// }
//
// if (Settings.AUTO_REFRESH_AUCTION_PAGES.getBoolean()) {
// makeMess();
// }
// });
//
// setOnClose(close -> {
// this.items.clear();
//
// if (Settings.AUTO_REFRESH_AUCTION_PAGES.getBoolean()) {
// cleanup();
// }
// });
// }
// public GUIAuctionHouseV3(AuctionPlayer auctionPlayer, String phrase) {
// this(auctionPlayer);
// this.searchPhrase = phrase;
// }
// private void partialReset() {
// if (inventory != null)
// inventory.clear();
//
// setActionForRange(0, 44, null);
// cellItems.clear();
// update();
// }
// public void draw() {
// try {
// partialReset();
// drawVariableButtons();// remove from here
// drawFixedButtons();
// drawItems();
// } catch (Exception e) {
// AuctionHouse.getInstance().getLogger().warning("Something stupid is happening during the draw process (Main Menu)");
// }
// }
// private void drawItems() {
// AuctionHouse.newChain().asyncFirst(() -> {
// this.items = new ArrayList<>();
//
// for (Map.Entry<UUID, AuctionedItem> entry : AuctionHouse.getInstance().getAuctionItemManager().getItems().entrySet()) {
// AuctionedItem auctionItem = entry.getValue();
// if (!auctionItem.isExpired() && !AuctionHouse.getInstance().getAuctionItemManager().getGarbageBin().containsKey(auctionItem.getId())) {
// if (Settings.PER_WORLD_ITEMS.getBoolean()) {
// if (auctionItem.getListedWorld() == null || this.auctionPlayer.getPlayer().getWorld().getName().equals(auctionItem.getListedWorld())) {
// this.items.add(auctionItem);
// }
// } else {
// this.items.add(auctionItem);
// }
// }
// }
//
// if (this.searchPhrase != null && this.searchPhrase.length() != 0) {
// this.items = this.items.stream().filter(item -> checkSearchCriteria(this.searchPhrase, item)).collect(Collectors.toList());
// }
//
// if (this.auctionPlayer != null) {
// if (this.auctionPlayer.getSelectedFilter() != AuctionItemCategory.ALL && this.auctionPlayer.getSelectedFilter() != AuctionItemCategory.SEARCH && this.auctionPlayer.getSelectedFilter() != AuctionItemCategory.SELF) {
// this.items = this.items.stream().filter(item -> checkFilterCriteria(item, this.auctionPlayer.getSelectedFilter())).collect(Collectors.toList());
// } else if (this.auctionPlayer.getSelectedFilter() == AuctionItemCategory.SELF) {
// this.items = this.items.stream().filter(item -> item.getOwner().equals(this.auctionPlayer.getPlayer().getUniqueId())).collect(Collectors.toList());
// } else if (this.auctionPlayer.getSelectedFilter() == AuctionItemCategory.SEARCH && this.auctionPlayer.getCurrentSearchPhrase().length() != 0) {
// this.items = this.items.stream().filter(item -> checkSearchCriteria(this.auctionPlayer.getCurrentSearchPhrase(), item)).collect(Collectors.toList());
// }
//
// if (this.auctionPlayer.getSelectedSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM) {
// this.items = this.items.stream().filter(AuctionedItem::isBidItem).collect(Collectors.toList());
// }
//
// if (this.auctionPlayer.getSelectedSaleType() == AuctionSaleType.WITHOUT_BIDDING_SYSTEM) {
// this.items = this.items.stream().filter(item -> !item.isBidItem()).collect(Collectors.toList());
// }
//
// if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.PRICE) {
// this.items = this.items.stream().sorted(Comparator.comparingDouble(AuctionedItem::getCurrentPrice).reversed()).collect(Collectors.toList());
// }
//
// if (this.auctionPlayer.getAuctionSortType() == AuctionSortType.RECENT) {
// this.items = this.items.stream().sorted(Comparator.comparingLong(AuctionedItem::getExpiresAt).reversed()).collect(Collectors.toList());
// }
// }
//
// this.items = this.items.stream().sorted(Comparator.comparing(AuctionedItem::isInfinite).reversed()).collect(Collectors.toList());
//
// return this.items.stream().skip((page - 1) * 45L).limit(45L).collect(Collectors.toList());
// }).asyncLast((data) -> {
// pages = (int) Math.max(1, Math.ceil(this.items.size() / (double) 45L));
// // todo possibly re-add variable btns draw
// drawPaginationButtons();
// placeItems(data);
// }).execute();
// }
// private boolean checkFilterCriteria(AuctionedItem auctionItem, AuctionItemCategory category) {
// // option for only whitelisted shit
// if (Settings.FILTER_ONLY_USES_WHITELIST.getBoolean()) {
// if (!Settings.FILTER_WHITELIST_USES_DURABILITY.getBoolean())
// return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.isSimilar(auctionItem.getItem()));
// else
// return AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.getType() == auctionItem.getItem().getType() && item.getDurability() == auctionItem.getItem().getDurability());
// }
//
// return auctionItem.getCategory() == category ||
// AuctionHouse.getInstance().getFilterManager().getFilterWhitelist(category).stream().anyMatch(item -> item.isSimilar(auctionItem.getItem()));
// }
// private boolean checkSearchCriteria(String phrase, AuctionedItem item) {
// ItemStack stack = item.getItem();
// return AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemName(stack)) ||
// AuctionAPI.getInstance().matchSearch(phrase, item.getCategory().getTranslatedType()) ||
// AuctionAPI.getInstance().matchSearch(phrase, stack.getType().name()) ||
// AuctionAPI.getInstance().matchSearch(phrase, Bukkit.getOfflinePlayer(item.getOwner()).getName()) ||
// AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemLore(stack)) ||
// AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemEnchantments(stack));
// }
/*
====================== CLICK HANDLES ======================
*/
// private void handleNonBidItem(AuctionedItem auctionItem, GuiClickEvent e, boolean buyingQuantity) {
// if (e.player.getUniqueId().equals(auctionItem.getOwner()) && !Settings.OWNER_CAN_PURCHASE_OWN_ITEM.getBoolean()) {
// AuctionHouse.getInstance().getLocale().getMessage("general.cantbuyown").sendPrefixedMessage(e.player);
// return;
// }
//
// if (!buyingQuantity)
// if (!EconomyManager.hasBalance(e.player, auctionItem.getBasePrice())) {
// AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
// return;
// }
//
// if (buyingQuantity) {
// if (auctionItem.getBidStartingPrice() <= 0 || !Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
// if (!Settings.ALLOW_PURCHASE_OF_SPECIFIC_QUANTITIES.getBoolean()) return;
// }
// }
//
// cleanup();
// e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, buyingQuantity));
// AuctionHouse.getInstance().getTransactionManager().addPrePurchase(e.player, auctionItem.getId());
// }
// private void handleBidItem(AuctionedItem auctionItem, GuiClickEvent e, boolean buyNow) {
// if (buyNow) {
// if (auctionItem.isBidItem()) {
// if (!Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) return;
// if (auctionItem.getBasePrice() <= -1) {
// AuctionHouse.getInstance().getLocale().getMessage("general.buynowdisabledonitem").sendPrefixedMessage(e.player);
// return;
// }
//
// if (e.player.getUniqueId().equals(auctionItem.getOwner()) && !Settings.OWNER_CAN_PURCHASE_OWN_ITEM.getBoolean()) {
// AuctionHouse.getInstance().getLocale().getMessage("general.cantbuyown").sendPrefixedMessage(e.player);
// return;
// }
//
// cleanup();
// e.manager.showGUI(e.player, new GUIConfirmPurchase(this.auctionPlayer, auctionItem, false));
// AuctionHouse.getInstance().getTransactionManager().addPrePurchase(e.player, auctionItem.getId());
// }
// return;
// }
//
// if (e.player.getUniqueId().equals(auctionItem.getOwner()) && !Settings.OWNER_CAN_BID_OWN_ITEM.getBoolean() || Settings.BIDDING_TAKES_MONEY.getBoolean() && e.player.getUniqueId().equals(auctionItem.getOwner())) {
// AuctionHouse.getInstance().getLocale().getMessage("general.cantbidonown").sendPrefixedMessage(e.player);
// return;
// }
//
// if (e.player.getUniqueId().equals(auctionItem.getHighestBidder()) && !Settings.ALLOW_REPEAT_BIDS.getBoolean()) {
// AuctionHouse.getInstance().getLocale().getMessage("general.alreadyhighestbidder").sendPrefixedMessage(e.player);
// return;
// }
//
// cleanup();
//
// if (Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
// e.gui.exit();
//
// new TitleInput(player, AuctionHouse.getInstance().getLocale().getMessage("titles.enter bid.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.enter bid.subtitle").getMessage()) {
//
// @Override
// public void onExit(Player player) {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouseV3(GUIAuctionHouseV3.this.auctionPlayer));
// }
//
// @Override
// public boolean onResult(String string) {
// string = ChatColor.stripColor(string);
//
// if (!NumberUtils.isDouble(string)) {
// AuctionHouse.getInstance().getLocale().getMessage("general.notanumber").processPlaceholder("value", string).sendPrefixedMessage(player);
// return false;
// }
//
// double value = Double.parseDouble(string);
//
// if (value <= 0) {
// AuctionHouse.getInstance().getLocale().getMessage("general.cannotbezero").sendPrefixedMessage(e.player);
// return false;
// }
//
// 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 false;
// }
//
// double newBiddingAmount = 0;
// if (Settings.USE_REALISTIC_BIDDING.getBoolean()) {
// if (value > auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice()) {
// newBiddingAmount = value;
// } else {
// if (Settings.BID_MUST_BE_HIGHER_THAN_PREVIOUS.getBoolean()) {
// e.manager.showGUI(e.player, new GUIAuctionHouseV3(GUIAuctionHouseV3.this.auctionPlayer));
// AuctionHouse.getInstance().getLocale().getMessage("pricing.bidmusthigherthanprevious").processPlaceholder("current_bid", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice())).sendPrefixedMessage(e.player);
// return true;
// }
//
// newBiddingAmount = auctionItem.getCurrentPrice() + value;
// }
// } else {
// newBiddingAmount = auctionItem.getCurrentPrice() + value;
// }
//
// newBiddingAmount = Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(newBiddingAmount) : newBiddingAmount;
//
// if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, newBiddingAmount)) {
// AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouseV3(GUIAuctionHouseV3.this.auctionPlayer));
// return true;
// }
//
// if (Settings.ASK_FOR_BID_CONFIRMATION.getBoolean()) {
// e.manager.showGUI(e.player, new GUIConfirmBid(GUIAuctionHouseV3.this.auctionPlayer, auctionItem, newBiddingAmount));
// return true;
// }
//
// ItemStack itemStack = auctionItem.getItem();
//
// OfflinePlayer oldBidder = Bukkit.getOfflinePlayer(auctionItem.getHighestBidder());
// OfflinePlayer owner = Bukkit.getOfflinePlayer(auctionItem.getOwner());
//
// AuctionBidEvent auctionBidEvent = new AuctionBidEvent(e.player, auctionItem, newBiddingAmount, true);
// Bukkit.getServer().getPluginManager().callEvent(auctionBidEvent);
// if (auctionBidEvent.isCancelled()) return true;
//
// if (Settings.BIDDING_TAKES_MONEY.getBoolean()) {
// final double oldBidAmount = auctionItem.getCurrentPrice();
//
// if (!EconomyManager.hasBalance(e.player, newBiddingAmount)) {
// AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
// return true;
// }
//
// if (e.player.getUniqueId().equals(owner.getUniqueId()) || oldBidder.getUniqueId().equals(e.player.getUniqueId())) {
// return true;
// }
//
// if (!auctionItem.getHighestBidder().equals(auctionItem.getOwner())) {
// if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
// AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
// oldBidder.getUniqueId(),
// oldBidAmount,
// auctionItem.getItem(),
// AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage(),
// PaymentReason.BID_RETURNED
// ), null);
// else
// EconomyManager.deposit(oldBidder, oldBidAmount);
// if (oldBidder.isOnline())
// AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(oldBidder))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(oldBidAmount)).sendPrefixedMessage(oldBidder.getPlayer());
// }
//
// EconomyManager.withdrawBalance(e.player, newBiddingAmount);
// AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(newBiddingAmount)).sendPrefixedMessage(e.player);
//
// }
//
// auctionItem.setHighestBidder(e.player.getUniqueId());
// auctionItem.setHighestBidderName(e.player.getName());
// auctionItem.setCurrentPrice(newBiddingAmount);
//
// if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
// auctionItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(auctionItem.getCurrentPrice()) : 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("player_displayname", AuctionAPI.getInstance().getDisplayName(e.player))
// .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
// .sendPrefixedMessage(oldBidder.getPlayer());
// }
//
// if (owner.isOnline()) {
// AuctionHouse.getInstance().getLocale().getMessage("auction.placedbid")
// .processPlaceholder("player", e.player.getName())
// .processPlaceholder("player_displayname", AuctionAPI.getInstance().getDisplayName(e.player))
// .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("player_displayname", AuctionAPI.getInstance().getDisplayName(e.player))
// .processPlaceholder("amount", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice()))
// .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemStack))
// .sendPrefixedMessage(player));
// }
//
// e.manager.showGUI(e.player, new GUIAuctionHouseV3(GUIAuctionHouseV3.this.auctionPlayer));
//
// return true;
// }
// };
//
// return;
// }
//
// e.manager.showGUI(e.player, new GUIBid(this.auctionPlayer, auctionItem));
// }
// private void handleItemRemove(AuctionedItem auctionItem, GuiClickEvent e) {
// if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin")) {
// cleanup();
// e.manager.showGUI(e.player, new GUIAdminItem(this.auctionPlayer, auctionItem));
// }
// }
// private void handleContainerInspect(GuiClickEvent e) {
// ItemStack clicked = e.clickedItem;
//
// if (BundleUtil.isBundledItem(clicked)) {
// cleanup();
// e.manager.showGUI(e.player, new GUIContainerInspect(this.auctionPlayer, e.clickedItem));
// return;
// }
//
// if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
// if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectshulker")) {
// if (!(clicked.getItemMeta() instanceof BlockStateMeta)) return;
//
// BlockStateMeta meta = (BlockStateMeta) clicked.getItemMeta();
// if (!(meta.getBlockState() instanceof ShulkerBox)) return;
// cleanup();
// e.manager.showGUI(e.player, new GUIContainerInspect(this.auctionPlayer, e.clickedItem));
// }
// }
// private void placeItems(List<AuctionedItem> data) {
//
// if (Settings.AUTO_REFRESH_DOES_SLOT_CLEAR.getBoolean())
// setItems(0, 44, getDefaultItem());
//
// int slot = 0;
// for (AuctionedItem auctionItem : data) {
// setButton(slot++, auctionItem.getDisplayStack(AuctionStackType.MAIN_AUCTION_HOUSE), e -> {
// // Non Type specific actions
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_INSPECT_CONTAINER.getString().toUpperCase())) {
// handleContainerInspect(e);
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_REMOVE_ITEM.getString().toUpperCase())) {
// handleItemRemove(auctionItem, e);
// return;
// }
//
// // Non Biddable Items
// if (!auctionItem.isBidItem()) {
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_NON_BID_ITEM_PURCHASE.getString().toUpperCase())) {
// handleNonBidItem(auctionItem, e, false);
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_NON_BID_ITEM_QTY_PURCHASE.getString().toUpperCase())) {
// if (!auctionItem.isAllowPartialBuy()) {
// AuctionHouse.getInstance().getLocale().getMessage("general.qtybuydisabled").processPlaceholder("item_owner", auctionItem.getOwnerName()).sendPrefixedMessage(e.player);
// return;
// }
//
// handleNonBidItem(auctionItem, e, true);
// return;
// }
// return;
// }
//
// // Biddable Items
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_BID_ITEM_PLACE_BID.getString().toUpperCase())) {
// handleBidItem(auctionItem, e, false);
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_BID_ITEM_BUY_NOW.getString().toUpperCase())) {
// handleBidItem(auctionItem, e, true);
// }
// });
// }
// }
/*
====================== FIXED BUTTONS ======================
*/
// private void drawVariableButtons() {
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), PlaceholderAPIHook.PAPIReplacer.tryReplace(this.auctionPlayer.getPlayer(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList()), new HashMap<String, Object>() {{
// put("%active_player_auctions%", auctionPlayer.getItems(false).size());
// put("%player_balance%", Settings.USE_SHORT_NUMBERS_ON_PLAYER_BALANCE.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(EconomyManager.getBalance(auctionPlayer.getPlayer())) : AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(auctionPlayer.getPlayer())));
// }}), e -> {
// cleanup();
// e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer));
// });
// }
//
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_COLLECTION_BIN_LORE.getStringList(), new HashMap<String, Object>() {{
// put("%expired_player_auctions%", auctionPlayer.getItems(true).size());
// }}), e -> {
// cleanup();
// e.manager.showGUI(e.player, new GUIExpiredItems(this.auctionPlayer));
// });
// }
//
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE.getStringList(), new HashMap<String, Object>() {{
// put("%total_items_bought%", AuctionHouse.getInstance().getTransactionManager().getTotalItemsBought(auctionPlayer.getPlayer().getUniqueId()));
// put("%total_items_sold%", AuctionHouse.getInstance().getTransactionManager().getTotalItemsSold(auctionPlayer.getPlayer().getUniqueId()));
// }}), e -> {
// if (Settings.RESTRICT_ALL_TRANSACTIONS_TO_PERM.getBoolean() && !e.player.hasPermission("auctionhouse.transactions.viewall")) {
// e.manager.showGUI(e.player, new GUITransactionList(e.player, false));
// } else {
// e.manager.showGUI(e.player, new GUITransactionType(e.player));
// }
// });
// }
// }
// private void drawPaginationButtons() {
// setItems(new int[]{Settings.GUI_PREV_PAGE_BTN_SLOT.getInt(), Settings.GUI_NEXT_PAGE_BTN_SLOT.getInt()}, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_FILLER.getString()));
//
// setPrevPage(Settings.GUI_PREV_PAGE_BTN_SLOT.getInt(), page == 1 ? ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_FILLER.getString()) : getPreviousPageItem());
//
// if (pages > page)
// setNextPage(Settings.GUI_NEXT_PAGE_BTN_SLOT.getInt(), getNextPageItem());
//
// setOnPage(e -> {
// draw();
// drawPaginationButtons();
//// SoundManager.getInstance().playSound(this.auctionPlayer.getPlayer(), Settings.SOUNDS_NAVIGATE_GUI_PAGES.getString());
// });
// }
// private void drawFixedButtons() {
// drawFilterButton();
//
// if (Settings.REPLACE_HOW_TO_SELL_WITH_LIST_BUTTON.getBoolean()) {
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_LIST_ITEM_LORE.getStringList(), null), e -> {
// // using this will ignore the "SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM" setting
// if (FloodGateHook.isFloodGateUser(e.player)) {
// AuctionHouse.getInstance().getLocale().getMessage("commands.no_permission").sendPrefixedMessage(e.player);
// return;
// }
//
// if (this.auctionPlayer.isAtItemLimit(this.player)) {
//// AuctionHouse.getInstance().getLocale().getMessage("general.sellinglimit").sendPrefixedMessage(player);
// return;
// }
//
// if (Settings.SELL_MENU_SKIPS_TYPE_SELECTION.getBoolean()) {
// if (Settings.FORCE_AUCTION_USAGE.getBoolean()) {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.AUCTION));
// return;
// }
//
// if (!Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, ListingType.BIN));
// return;
// }
//
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
// }));
//
// } else {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellListingType(this.auctionPlayer, selected -> {
// AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellPlaceItem(this.auctionPlayer, GUISellPlaceItem.ViewMode.SINGLE_ITEM, selected));
// }));
// }
//
// });
// }
// } else {
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_LORE.getStringList(), null), null);
// }
// }
//
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_GUIDE_LORE.getStringList(), null), null);
// }
//
// if (Settings.GUI_REFRESH_BTN_ENABLED.getBoolean()) {
// setButton(Settings.GUI_REFRESH_BTN_SLOT.getInt(), getRefreshButtonItem(), e -> {
// if (Settings.USE_REFRESH_COOL_DOWN.getBoolean()) {
// if (AuctionHouse.getInstance().getAuctionPlayerManager().getCooldowns().containsKey(this.auctionPlayer.getPlayer().getUniqueId())) {
// if (AuctionHouse.getInstance().getAuctionPlayerManager().getCooldowns().get(this.auctionPlayer.getPlayer().getUniqueId()) > System.currentTimeMillis()) {
// return;
// }
// }
// AuctionHouse.getInstance().getAuctionPlayerManager().addCooldown(this.auctionPlayer.getPlayer().getUniqueId());
// }
// cleanup();
// e.manager.showGUI(e.player, new GUIAuctionHouseV3(this.auctionPlayer));
// });
// }
// }
// private void drawFilterButton() {
// if (Settings.USE_SEPARATE_FILTER_MENU.getBoolean()) {
// String materialToBeUsed = Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_ITEM.getString();
// switch (auctionPlayer.getSelectedFilter()) {
// case ALL:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_ALL_ITEM.getString();
// break;
// case ARMOR:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_ARMOR_ITEM.getString();
// break;
// case BLOCKS:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_BLOCKS_ITEM.getString();
// break;
// case TOOLS:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_TOOLS_ITEM.getString();
// break;
// case WEAPONS:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_WEAPONS_ITEM.getString();
// break;
// case SPAWNERS:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_SPAWNERS_ITEM.getString();
// break;
// case ENCHANTS:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_ENCHANTS_ITEM.getString();
// break;
// case MISC:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_MISC_ITEM.getString();
// break;
// case SEARCH:
// materialToBeUsed = Settings.GUI_FILTER_ITEMS_SEARCH_ITEM.getString();
// break;
// case SELF:
// materialToBeUsed = "PLAYER_HEAD";
// break;
// }
//
// HashMap<String, Object> replacements = new HashMap<String, Object>() {{
// put("%filter_category%", auctionPlayer.getSelectedFilter().getTranslatedType());
// put("%filter_auction_type%", auctionPlayer.getSelectedSaleType().getTranslatedType());
// put("%filter_sort_order%", auctionPlayer.getAuctionSortType().getTranslatedType());
// }};
//
// ItemStack item = materialToBeUsed.equalsIgnoreCase("PLAYER_HEAD") ? ConfigurationItemHelper.createConfigurationItem(this.player, AuctionAPI.getInstance().getPlayerHead(this.auctionPlayer.getPlayer().getName()), Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_LORE.getStringList(), replacements) : ConfigurationItemHelper.createConfigurationItem(this.player, materialToBeUsed, Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_LORE.getStringList(), replacements);
//
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_MENU_SLOT.getInt(), item, e -> {
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_CATEGORY.getString().toUpperCase())) {
// e.manager.showGUI(e.player, new GUIFilterSelection(this.auctionPlayer));
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_RESET.getString().toUpperCase())) {
// this.auctionPlayer.resetFilter();
// updatePlayerFilter(this.auctionPlayer);
// draw();
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_SORT_SALE_TYPE.getString().toUpperCase())) {
// if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
// this.auctionPlayer.setSelectedSaleType(this.auctionPlayer.getSelectedSaleType().next());
// updatePlayerFilter(this.auctionPlayer);
// draw();
// }
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_SORT_PRICE_OR_RECENT.getString().toUpperCase())) {
// this.auctionPlayer.setAuctionSortType(this.auctionPlayer.getAuctionSortType().next());
// updatePlayerFilter(this.auctionPlayer);
// draw();
// }
// });
// }
// return;
// }
//
// if (Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_ENABLED.getBoolean()) {
// setButton(Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_SLOT.getInt(), ConfigurationItemHelper.createConfigurationItem(
// this.player,
// this.auctionPlayer.getSelectedFilter().getFilterIcon(),
// Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_NAME.getString(),
// Settings.GUI_AUCTION_HOUSE_ITEMS_FILTER_LORE.getStringList(),
// new HashMap<String, Object>() {{
// put("%filter_category%", auctionPlayer.getSelectedFilter().getTranslatedType());
// put("%filter_auction_type%", auctionPlayer.getSelectedSaleType().getTranslatedType());
// put("%filter_sort_order%", auctionPlayer.getAuctionSortType().getTranslatedType());
// }}), e -> {
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_CATEGORY.getString().toUpperCase())) {
// this.auctionPlayer.setSelectedFilter(this.auctionPlayer.getSelectedFilter().next());
// updatePlayerFilter(this.auctionPlayer);
// draw();
//
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_RESET.getString().toUpperCase())) {
// this.auctionPlayer.resetFilter();
// updatePlayerFilter(this.auctionPlayer);
// draw();
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_SORT_SALE_TYPE.getString().toUpperCase())) {
// if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
// this.auctionPlayer.setSelectedSaleType(this.auctionPlayer.getSelectedSaleType().next());
// updatePlayerFilter(this.auctionPlayer);
// draw();
// }
// return;
// }
//
// if (e.clickType == ClickType.valueOf(Settings.CLICKS_FILTER_SORT_PRICE_OR_RECENT.getString().toUpperCase())) {
// this.auctionPlayer.setAuctionSortType(this.auctionPlayer.getAuctionSortType().next());
// updatePlayerFilter(this.auctionPlayer);
// draw();
// }
// });
// }
// }
/*
====================== AUTO REFRESH ======================
*/
// private void makeMess() {
// task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(AuctionHouse.getInstance(), this::drawItems, 0L, (long) 20 * Settings.TICK_UPDATE_GUI_TIME.getInt());
// }
// private void cleanup() {
// if (task != null) {
// task.cancel();
// }
// }
// private void updatePlayerFilter(AuctionPlayer player) {
// AuctionHouse.getInstance().getDataManager().updateAuctionPlayer(player, (error, success) -> {
// if (error == null && success)
// if (!Settings.DISABLE_PROFILE_UPDATE_MSG.getBoolean())
// AuctionHouse.getInstance().getLogger().info("Updating profile for player: " + player.getPlayer().getName());
//
// });
// }
}

View File

@ -18,7 +18,7 @@
package ca.tweetzy.auctionhouse.guis.abstraction;
import ca.tweetzy.flight.gui.Gui;
import ca.tweetzy.core.gui.Gui;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.entity.Player;

View File

@ -20,9 +20,9 @@ package ca.tweetzy.auctionhouse.guis.abstraction;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.gui.Gui;
import ca.tweetzy.flight.gui.events.GuiClickEvent;
import ca.tweetzy.flight.gui.template.BaseGUI;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.core.gui.BaseGUI;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.flight.utils.QuickItem;
import lombok.Getter;

View File

@ -20,13 +20,13 @@ package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.events.AuctionEndEvent;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
import ca.tweetzy.auctionhouse.auction.enums.PaymentReason;
import ca.tweetzy.auctionhouse.events.AuctionEndEvent;
import ca.tweetzy.auctionhouse.exception.ItemNotFoundException;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
@ -47,6 +47,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.HashMap;
import java.util.UUID;
/**
* The current file has been created by Kiran Hart
@ -102,10 +103,11 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui {
private void draw() {
ItemStack deserializeItem = this.auctionItem.getItem().clone();
final boolean isRequest = this.auctionItem.isRequest();
setItems(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, getConfirmBuyYesItem());
setItem(this.buyingSpecificQuantity ? 1 : 0, 4, this.auctionItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW));
setItems(this.buyingSpecificQuantity ? 14 : 5, this.buyingSpecificQuantity ? 17 : 8, getConfirmBuyNoItem());
setItems(this.buyingSpecificQuantity ? 9 : 0, this.buyingSpecificQuantity ? 12 : 3, isRequest ? getConfirmRequestYesItem() : getConfirmBuyYesItem());
setItem(this.buyingSpecificQuantity ? 1 : 0, 4, isRequest ? this.auctionItem.getDisplayRequestStack(AuctionStackType.MAIN_AUCTION_HOUSE) : this.auctionItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW));
setItems(this.buyingSpecificQuantity ? 14 : 5, this.buyingSpecificQuantity ? 17 : 8, isRequest ? getConfirmRequestNoItem() : getConfirmBuyNoItem());
setAction(this.buyingSpecificQuantity ? 1 : 0, 4, ClickType.LEFT, e -> {
if (deserializeItem.getItemMeta() instanceof BlockStateMeta) {
@ -137,6 +139,69 @@ public class GUIConfirmPurchase extends AbstractPlaceholderGui {
double buyNowPrice = this.buyingSpecificQuantity ? this.purchaseQuantity * this.pricePerItem : located.getBasePrice();
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * buyNowPrice : 0D;
/*
============================================================================
SPECIAL SHIT FOR REQUESTS
============================================================================
*/
if (isRequest) {
// check if the fulfiller even has the item
final int itemCount = AuctionAPI.getInstance().getItemCountInPlayerInventory(this.player, this.auctionItem.getItem());
if (itemCount < this.auctionItem.getItem().getAmount()) {
// yell at fulfiller for being dumb
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughitems").sendPrefixedMessage(e.player);
return;
}
final OfflinePlayer requester = Bukkit.getOfflinePlayer(this.auctionItem.getOwner());
// check if the requester even has money
if (!EconomyManager.hasBalance(requester, buyNowPrice)) {
AuctionHouse.getInstance().getLocale().getMessage("general.requesterhasnomoney").sendPrefixedMessage(e.player);
return;
}
// transfer funds
EconomyManager.withdrawBalance(requester, buyNowPrice);
EconomyManager.deposit(e.player, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? buyNowPrice : buyNowPrice - tax);
// transfer items
AuctionAPI.getInstance().removeSpecificItemQuantityFromPlayer(this.player, this.auctionItem.getItem(), this.auctionItem.getItem().getAmount());
final AuctionedItem toGive = new AuctionedItem(
UUID.randomUUID(),
requester.getUniqueId(),
requester.getUniqueId(),
this.auctionItem.getOwnerName(),
this.auctionItem.getOwnerName(),
this.auctionItem.getCategory(),
this.auctionItem.getItem(),
0,
0,
0,
0,
false, true, System.currentTimeMillis()
);
AuctionHouse.getInstance().getDataManager().insertAuctionAsync(toGive, (error, inserted) -> AuctionHouse.getInstance().getAuctionItemManager().addAuctionItem(toGive));
AuctionHouse.getInstance().getAuctionItemManager().sendToGarbage(this.auctionItem);
AuctionHouse.getInstance().getTransactionManager().getPrePurchasePlayers(auctionItem.getId()).forEach(player -> {
AuctionHouse.getInstance().getTransactionManager().removeAllRelatedPlayers(auctionItem.getId());
player.closeInventory();
});
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(e.player);
if (requester.isOnline())
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(requester.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(this.auctionItem.getBasePrice())).sendPrefixedMessage(requester.getPlayer());
e.gui.close();
return;
}
// languageNodes.put("pricing.moneyremove", "&c&l- $%price% &7(%player_balance%)");
// languageNodes.put("pricing.moneyadd", "&a&l+ $%price% &7(%player_balance%)");
// Check economy
if (!EconomyManager.hasBalance(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);

View File

@ -21,12 +21,12 @@ package ca.tweetzy.auctionhouse.helpers;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.api.auction.ListingResult;
import ca.tweetzy.auctionhouse.events.AuctionStartEvent;
import ca.tweetzy.auctionhouse.hooks.McMMOHook;
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.PaymentReason;
import ca.tweetzy.auctionhouse.events.AuctionStartEvent;
import ca.tweetzy.auctionhouse.hooks.McMMOHook;
import ca.tweetzy.auctionhouse.managers.SoundManager;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.hooks.EconomyManager;
@ -64,7 +64,7 @@ public final class AuctionCreator {
// Check if player is even valid?!?
// only check if not a server item
if (!auctionItem.isServerItem()) {
if (!auctionItem.isServerItem() && !auctionItem.isRequest()) {
if (seller == null) {
result.accept(auctionItem, PLAYER_INSTANCE_NOT_FOUND);
return;
@ -90,10 +90,11 @@ public final class AuctionCreator {
}
}
if (!AuctionAPI.getInstance().meetsMinItemPrice(BundleUtil.isBundledItem(auctionItem.getItem()), auctionItem.isBidItem(), auctionItem.getItem(), auctionItem.getBasePrice(), auctionItem.getBidStartingPrice())) {
instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(auctionItem.getItem()).getPrice())).sendPrefixedMessage(seller);
return;
}
if (!auctionItem.isRequest())
if (!AuctionAPI.getInstance().meetsMinItemPrice(BundleUtil.isBundledItem(auctionItem.getItem()), auctionItem.isBidItem(), auctionItem.getItem(), auctionItem.getBasePrice(), auctionItem.getBidStartingPrice())) {
instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getMinItemPriceManager().getMinPrice(auctionItem.getItem()).getPrice())).sendPrefixedMessage(seller);
return;
}
final ItemStack finalItemToSell = auctionItem.getItem().clone();
final double originalBasePrice = auctionItem.getBasePrice();
@ -111,7 +112,7 @@ public final class AuctionCreator {
final double listingFee = Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() ? AuctionAPI.getInstance().calculateListingFee(originalBasePrice) : 0;
// check tax
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem()) {
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem() && !auctionItem.isRequest()) {
if (!EconomyManager.hasBalance(seller, listingFee)) {
instance.getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(listingFee)).sendPrefixedMessage(seller);
result.accept(auctionItem, CANNOT_PAY_LISTING_FEE);
@ -128,21 +129,24 @@ public final class AuctionCreator {
auctionItem.setListedWorld(seller.getWorld().getName());
AuctionStartEvent startEvent = new AuctionStartEvent(seller, auctionItem, listingFee);
// check if not request
if (!auctionItem.isRequest()) {
AuctionStartEvent startEvent = new AuctionStartEvent(seller, auctionItem, listingFee);
if (Bukkit.isPrimaryThread())
Bukkit.getServer().getPluginManager().callEvent(startEvent);
else
Bukkit.getScheduler().runTask(AuctionHouse.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(startEvent));
if (Bukkit.isPrimaryThread())
Bukkit.getServer().getPluginManager().callEvent(startEvent);
else
Bukkit.getScheduler().runTask(AuctionHouse.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(startEvent));
if (startEvent.isCancelled()) {
result.accept(auctionItem, EVENT_CANCELED);
return;
if (startEvent.isCancelled()) {
result.accept(auctionItem, EVENT_CANCELED);
return;
}
}
// overwrite to be random uuid since it's a server auction
if (auctionItem.isServerItem()) {
if (auctionItem.isServerItem() && !auctionItem.isRequest()) {
auctionItem.setOwner(SERVER_AUCTION_UUID);
auctionItem.setOwnerName(SERVER_LISTING_NAME);
@ -159,7 +163,7 @@ public final class AuctionCreator {
String NAX = AuctionHouse.getInstance().getLocale().getMessage("auction.biditemwithdisabledbuynow").getMessage();
String msg = AuctionHouse.getInstance().getLocale().getMessage(auctionItem.isBidItem() ? "auction.listed.withbid" : "auction.listed.nobid")
String msg = AuctionHouse.getInstance().getLocale().getMessage(auctionItem.isRequest() ? "auction.listed.request" : auctionItem.isBidItem() ? "auction.listed.withbid" : "auction.listed.nobid")
.processPlaceholder("amount", finalItemToSell.getAmount())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(finalItemToSell))
.processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()))
@ -194,17 +198,19 @@ public final class AuctionCreator {
ItemStack originalCopy = auctionItem.getItem().clone();
int totalOriginal = BundleUtil.isBundledItem(originalCopy) ? AuctionAPI.getInstance().getItemCountInPlayerInventory(seller, originalCopy) : originalCopy.getAmount();
if (BundleUtil.isBundledItem(originalCopy)) {
originalCopy.setAmount(1);
for (int i = 0; i < totalOriginal; i++) PlayerUtils.giveItem(seller, originalCopy);
} else {
originalCopy.setAmount(totalOriginal);
PlayerUtils.giveItem(seller, originalCopy);
if (!auctionItem.isRequest()) {
if (BundleUtil.isBundledItem(originalCopy)) {
originalCopy.setAmount(1);
for (int i = 0; i < totalOriginal; i++) PlayerUtils.giveItem(seller, originalCopy);
} else {
originalCopy.setAmount(totalOriginal);
PlayerUtils.giveItem(seller, originalCopy);
}
}
}
// If the item could not be added for whatever reason and the tax listing fee is enabled, refund them
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem() && seller != null) {
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean() && !auctionItem.isServerItem() && !auctionItem.isRequest() && seller != null) {
if (Settings.STORE_PAYMENTS_FOR_MANUAL_COLLECTION.getBoolean())
AuctionHouse.getInstance().getDataManager().insertAuctionPayment(new AuctionPayment(
seller.getUniqueId(),
@ -226,7 +232,7 @@ public final class AuctionCreator {
//====================================================================================
// ANOTHER VERY SHIT BROADCAST THAT IS IN FACT BROKEN
if (Settings.BROADCAST_AUCTION_LIST.getBoolean()) {
if (Settings.BROADCAST_AUCTION_LIST.getBoolean() && !auctionItem.isRequest()) {
final String prefix = AuctionHouse.getInstance().getLocale().getMessage("general.prefix").getMessage();

View File

@ -44,6 +44,8 @@ public class LocaleSettings {
languageNodes.put("general.locked", "&cThe Auction House is currently locked!");
languageNodes.put("general.playernotfound", "&cCould not find the player &4%player%");
languageNodes.put("general.notenoughmoney", "&cYou do not have enough money!");
languageNodes.put("general.requesterhasnomoney", "&cRequester does not have enough money!");
languageNodes.put("general.notenoughitems", "&cYou do not have enough of that item!");
languageNodes.put("general.cannotbezero", "&cPlease provide a number greater than zero");
languageNodes.put("general.cantbidonown", "&cYou cannot bid on your own item!");
languageNodes.put("general.alreadyhighestbidder", "&cYou are already the highest bidder!");
@ -58,6 +60,7 @@ public class LocaleSettings {
languageNodes.put("general.min item price air", "&cSorry, but you cannot add a price to air");
languageNodes.put("general.blocked", "&cSorry, you are not allowed to sell &e%item%");
languageNodes.put("general.sellinglimit", "&cYou cannot sell more items, please remove/sell current active items");
languageNodes.put("general.requestlimit", "&cYou cannot request more items, please remove/sell current active items");
languageNodes.put("general.collectionbinlimit", "&cCollection is full, please claim your items first.");
languageNodes.put("general.bundlelistlimit", "&cYou cannot list anymore bundled items!");
languageNodes.put("general.noroom", "&cPlease clear room in your inventory to purchase that item.");
@ -182,6 +185,7 @@ public class LocaleSettings {
languageNodes.put("auction.listed.withbid", "&eListed &fx%amount% &6%item% &e&lBuy Now&f: &a%base_price% &e&lStarting&f: &a%start_price% &e&lIncrement&f: &a%increment_price%");
languageNodes.put("auction.listed.nobid", "&eListed &fx%amount% &6%item% &efor &a%base_price%");
languageNodes.put("auction.listed.request", "&eRequested &fx%amount% &6%item%&f(s) &efor &a%base_price%");
languageNodes.put("auction.broadcast.withbid", "&e%player% listed &fx%amount% &6%item% &e&lBuy Now&f: &a%base_price% &e&lStarting&f: &a%start_price% &e&lIncrement&f: &a%increment_price%");
languageNodes.put("auction.broadcast.nobid", "&e%player% listed &fx%amount% &6%item% &efor &a%base_price%");
languageNodes.put("auction.broadcast.sold", "&e&fx%amount% &6%item% &esold to %player% for &a%price%");
@ -234,6 +238,7 @@ public class LocaleSettings {
languageNodes.put("commands.syntax.markchest", "markchest");
languageNodes.put("commands.syntax.min price", "minprices [add] [price]");
languageNodes.put("commands.syntax.stats", "stats [player]");
languageNodes.put("commands.syntax.request", "request <price> [-single]");
languageNodes.put("commands.description.active", "View all your auction listings");
languageNodes.put("commands.description.auctionhouse", "Main command for the plugin, it opens the auction window.");
@ -252,6 +257,7 @@ public class LocaleSettings {
languageNodes.put("commands.description.markchest", "Toggles whether a chest is an auction chest");
languageNodes.put("commands.description.min price", "Adds a minimum sell price to an item");
languageNodes.put("commands.description.stats", "View yours or another players stats");
languageNodes.put("commands.description.request", "Makes request for item your holding");
}
public static void send(CommandSender sender, String msg) {

View File

@ -638,6 +638,18 @@ public class Settings {
"&7Click to confirm your purchase"
));
public static final ConfigSetting GUI_CONFIRM_REQUEST_NO_ITEM = new ConfigSetting(config, "gui.confirm request.no.item", "RED_STAINED_GLASS_PANE");
public static final ConfigSetting GUI_CONFIRM_REQUEST_NO_NAME = new ConfigSetting(config, "gui.confirm request.no.name", "&c&LCancel");
public static final ConfigSetting GUI_CONFIRM_REQUEST_NO_LORE = new ConfigSetting(config, "gui.confirm request.no.lore", Collections.singletonList(
"&7Click to cancel your purchase"
));
public static final ConfigSetting GUI_CONFIRM_REQUEST_YES_ITEM = new ConfigSetting(config, "gui.confirm request.yes.item", "LIME_STAINED_GLASS_PANE");
public static final ConfigSetting GUI_CONFIRM_REQUEST_YES_NAME = new ConfigSetting(config, "gui.confirm request.yes.name", "&a&lConfirm");
public static final ConfigSetting GUI_CONFIRM_REQUEST_YES_LORE = new ConfigSetting(config, "gui.confirm request.yes.lore", Collections.singletonList(
"&7Click to confirm your purchase"
));
/* ===============================
* CONFIRM LISTING GUI
* ===============================*/
@ -1315,6 +1327,15 @@ public class Settings {
""
));
public static final ConfigSetting AUCTION_STACK_DETAILS_REQUESTER = new ConfigSetting(config, "auction stack.requester lines", Arrays.asList(
"&eRequester&f: &b%requester%",
""
));
public static final ConfigSetting AUCTION_STACK_DETAILS_REQUEST_PRICE = new ConfigSetting(config, "auction stack.request price lines", Arrays.asList(
"&eOffering: &a$%request_price%",
""
));
public static final ConfigSetting AUCTION_STACK_DETAILS_BUY_NOW = new ConfigSetting(config, "auction stack.buy now lines", Arrays.asList(
"&eBuy Now: &a$%buynowprice%",
""
@ -1348,6 +1369,7 @@ public class Settings {
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_INSPECTION = new ConfigSetting(config, "auction stack.controls.inspection", Collections.singletonList("&eShift Right-Click to inspect"), "This will only be added to the control lore if the item can be inspected (skulker box/bundled item)");
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_ACCEPT_BID = new ConfigSetting(config, "auction stack.controls.accept bid", Collections.singletonList("&eRight-Click to accept the current bid"), "This will only show on items within the active listings menu on biddable items.");
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_CANCEL_ITEM = new ConfigSetting(config, "auction stack.controls.cancel item", Collections.singletonList("&eLeft-Click to cancel this listing"));
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_CANCEL_REQUEST = new ConfigSetting(config, "auction stack.controls.cancel request", Collections.singletonList("&eLeft-Click to cancel this request"));
public static final ConfigSetting AUCTION_STACK_LISTING_PREVIEW_ITEM = new ConfigSetting(config, "auction stack.controls.preview item", Collections.singletonList("&ePreviewing Listing"));
public static final ConfigSetting AUCTION_STACK_HIGHEST_BIDDER_ITEM = new ConfigSetting(config, "auction stack.controls.highest bidder", Collections.singletonList("&eCurrently Winning!"));
@ -1360,6 +1382,9 @@ public class Settings {
"&eLeft-Click&f: &bBid"
), "This will be appended at the end of the lore", "If the auction item is using a bid, this will show");
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_FULFILL_REQUEST = new ConfigSetting(config, "auction stack.controls.fulfill request", Collections.singletonList(
"&eLeft-Click&f: &bFulfill Request"
), "This will be appended at the end of the lore", "If the listing is a request this will be shown to fulfill");
public static final ConfigSetting AUCTION_STACK_PURCHASE_CONTROLS_BID_OFF = new ConfigSetting(config, "auction stack.controls.not using bid", Collections.singletonList(
"&eLeft-Click&f: &bBuy Now"

View File

@ -18,7 +18,6 @@
package ca.tweetzy.auctionhouse.settings.v3;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionUsageMode;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.config.ConfigEntry;

View File

@ -119,7 +119,7 @@ public class TickAuctionsTask extends BukkitRunnable {
// the owner is the highest bidder, so just expire
if (auctionItem.getHighestBidder().equals(auctionItem.getOwner())) {
if (auctionItem.isServerItem())
if (auctionItem.isServerItem() || auctionItem.isRequest())
instance.getAuctionItemManager().sendToGarbage(auctionItem);
else
auctionItem.setExpired(true);