This commit is contained in:
Kiran Hart 2021-07-17 18:29:54 -04:00
parent d4b3147fed
commit 09e356990f
4 changed files with 29 additions and 12 deletions

View File

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

View File

@ -6,6 +6,7 @@ import ca.tweetzy.auctionhouse.guis.GUISellItem;
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.compatibility.CompatibleHand;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.utils.PlayerUtils;
import org.bukkit.command.CommandSender;
@ -69,7 +70,17 @@ public class CommandAdmin extends AbstractCommand {
if (args.length < 2) return ReturnType.FAILURE;
Player player = PlayerUtils.findPlayer(args[1]);
if (player == null) return ReturnType.FAILURE;
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellItem(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()), PlayerHelper.getHeldItem(player)));
ItemStack itemToSell = PlayerHelper.getHeldItem(player).clone();
if (itemToSell.getType() == XMaterial.AIR.parseMaterial() && Settings.SELL_MENU_REQUIRES_USER_TO_HOLD_ITEM.getBoolean()) {
AuctionHouse.getInstance().getLocale().getMessage("general.air").sendPrefixedMessage(player);
return ReturnType.FAILURE;
} else {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUISellItem(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()), itemToSell));
AuctionHouse.getInstance().getAuctionPlayerManager().addItemToSellHolding(player.getUniqueId(), itemToSell);
PlayerUtils.takeActiveItem(player, CompatibleHand.MAIN_HAND, itemToSell.getAmount());
}
break;
}

View File

@ -71,7 +71,11 @@ public class GUISellItem extends Gui {
if (toGiveBack != null && toGiveBack.getType() != XMaterial.AIR.parseMaterial()) {
PlayerUtils.giveItem(close.player, toGiveBack);
} else {
PlayerUtils.giveItem(close.player, getItem(1, 4));
if (this.itemToBeListed == null || this.itemToBeListed.getType() == XMaterial.AIR.parseMaterial()) {
PlayerUtils.giveItem(close.player, getItem(1, 4));
} else {
PlayerUtils.giveItem(close.player, this.itemToBeListed);
}
}
AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().remove(close.player.getUniqueId());
@ -97,6 +101,8 @@ public class GUISellItem extends Gui {
e.event.setCancelled(true);
}
}
this.itemToBeListed = e.clickedItem;
});
setButton(3, 1, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_BUY_NOW_ITEM.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_NAME.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_LORE.getStringList(), new HashMap<String, Object>() {{
@ -157,15 +163,15 @@ public class GUISellItem extends Gui {
}
setButton(3, 5, ConfigurationItemHelper.createConfigurationItem(this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_ITEM.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_NAME.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_LORE.getStringList(), null), e -> {
if (!Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
return;
}
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
setButton(3, 5, ConfigurationItemHelper.createConfigurationItem(this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_ITEM.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_NAME.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_LORE.getStringList(), null), e -> {
this.isBiddingItem = !this.isBiddingItem;
setTheItemToBeListed();
draw();
});
this.isBiddingItem = !this.isBiddingItem;
setTheItemToBeListed();
draw();
});
}
setButton(3, 7, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_CONFIRM_LISTING_ITEM.getString(), Settings.GUI_SELL_ITEMS_CONFIRM_LISTING_NAME.getString(), Settings.GUI_SELL_ITEMS_CONFIRM_LISTING_LORE.getStringList(), null), e -> {
// if the item in the sell slot is null then stop the listing

View File

@ -53,7 +53,7 @@ public class GUIFilterSelection extends Gui {
put("%filter_search_phrase%", auctionPlayer.getCurrentSearchPhrase());
}}), e -> {
e.gui.exit();
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), AuctionHouse.getInstance().getLocale().getMessage("general.entersearchphrase").getMessage(), chat -> {
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("general.entersearchphrase").getMessage()), chat -> {
if (chat.getMessage() != null && chat.getMessage().length() !=0) {
// the keyword is valid
this.auctionPlayer.setCurrentSearchPhrase(chat.getMessage().trim());