mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-08 12:57:35 +01:00
bid confirm option
This commit is contained in:
parent
a6362a9972
commit
765eb3903f
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<version>2.8.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -183,16 +183,22 @@ public class GUIAuctionHouse extends Gui {
|
||||
return;
|
||||
}
|
||||
|
||||
auctionItem.setHighestBidder(e.player.getUniqueId());
|
||||
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice());
|
||||
|
||||
if (Settings.INCREASE_TIME_ON_BID.getBoolean()) {
|
||||
auctionItem.setRemainingTime(auctionItem.getRemainingTime() + Settings.TIME_TO_INCREASE_BY_ON_BID.getInt());
|
||||
}
|
||||
|
||||
if (Settings.REFRESH_GUI_WHEN_BID.getBoolean()) {
|
||||
// TODO CLEAN UP THIS
|
||||
if (Settings.ASK_FOR_BID_CONFIRMATION.getBoolean()) {
|
||||
cleanup();
|
||||
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem));
|
||||
} else {
|
||||
auctionItem.setHighestBidder(e.player.getUniqueId());
|
||||
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice());
|
||||
|
||||
if (Settings.INCREASE_TIME_ON_BID.getBoolean()) {
|
||||
auctionItem.setRemainingTime(auctionItem.getRemainingTime() + Settings.TIME_TO_INCREASE_BY_ON_BID.getInt());
|
||||
}
|
||||
|
||||
if (Settings.REFRESH_GUI_WHEN_BID.getBoolean()) {
|
||||
cleanup();
|
||||
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -210,14 +216,14 @@ public class GUIAuctionHouse extends Gui {
|
||||
break;
|
||||
case SHIFT_RIGHT:
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) return;
|
||||
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectshulker")) {
|
||||
if (e.player.isOp() || e.player.hasPermission("auctionhouse.admin") || e.player.hasPermission("auctionhouse.inspectcontainer")) {
|
||||
ItemStack clicked = e.clickedItem;
|
||||
if (!(clicked.getItemMeta() instanceof BlockStateMeta)) return;
|
||||
|
||||
BlockStateMeta meta = (BlockStateMeta) clicked.getItemMeta();
|
||||
if (!(meta.getBlockState() instanceof ShulkerBox)) return;
|
||||
cleanup();
|
||||
e.manager.showGUI(e.player, new GUIShulkerInspect(e.clickedItem));
|
||||
e.manager.showGUI(e.player, new GUIContainerInspect(e.clickedItem));
|
||||
}
|
||||
break;
|
||||
case RIGHT:
|
||||
|
@ -0,0 +1,74 @@
|
||||
package ca.tweetzy.auctionhouse.guis;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.managers.SoundManager;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.gui.Gui;
|
||||
import ca.tweetzy.core.gui.events.GuiClickEvent;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.TItemBuilder;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
* Date Created: March 17 2021
|
||||
* Time Created: 11:18 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class GUIConfirmBid extends Gui {
|
||||
|
||||
final AuctionPlayer auctionPlayer;
|
||||
final AuctionItem auctionItem;
|
||||
|
||||
public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionItem auctionItem) {
|
||||
this.auctionPlayer = auctionPlayer;
|
||||
this.auctionItem = auctionItem;
|
||||
setTitle(TextUtils.formatText(Settings.GUI_CONFIRM_BID_TITLE.getString()));
|
||||
setAcceptsItems(false);
|
||||
draw();
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BID_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BID_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_BID_YES_LORE.getStringList()).toItemStack());
|
||||
setItem(0, 4, AuctionAPI.getInstance().deserializeItem(this.auctionItem.getRawItem()));
|
||||
setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_BID_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_BID_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_BID_NO_LORE.getStringList()).toItemStack());
|
||||
|
||||
setActionForRange(5, 8, ClickType.LEFT, e -> e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer)));
|
||||
setActionForRange(0, 3, ClickType.LEFT, e -> {
|
||||
// Re-select the item to ensure that it's available
|
||||
AuctionItem located = AuctionHouse.getInstance().getAuctionItemManager().getItem(this.auctionItem.getKey());
|
||||
if (located == null) {
|
||||
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getInstance().getEconomy().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
|
||||
return;
|
||||
}
|
||||
|
||||
auctionItem.setHighestBidder(e.player.getUniqueId());
|
||||
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice());
|
||||
|
||||
if (Settings.INCREASE_TIME_ON_BID.getBoolean()) {
|
||||
auctionItem.setRemainingTime(auctionItem.getRemainingTime() + Settings.TIME_TO_INCREASE_BY_ON_BID.getInt());
|
||||
}
|
||||
|
||||
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
|
||||
});
|
||||
}
|
||||
}
|
@ -17,18 +17,18 @@ import java.util.Arrays;
|
||||
* Time Created: 12:28 p.m.
|
||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||
*/
|
||||
public class GUIShulkerInspect extends Gui {
|
||||
public class GUIContainerInspect extends Gui {
|
||||
|
||||
final int[] fillSlots = {0, 1, 2, 3, 4, 5, 6, 7, 8, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 50, 51, 52, 53};
|
||||
final ItemStack shulker;
|
||||
final ItemStack container;
|
||||
|
||||
/**
|
||||
* Used to inspect a shulker box from it's item stack.
|
||||
*
|
||||
* @param shulker is the shulker box
|
||||
* @param container is the shulker box
|
||||
*/
|
||||
public GUIShulkerInspect(ItemStack shulker) {
|
||||
this.shulker = shulker;
|
||||
public GUIContainerInspect(ItemStack container) {
|
||||
this.container = container;
|
||||
setTitle(TextUtils.formatText(Settings.GUI_SHULKER_INSPECT_TITLE.getString()));
|
||||
setDefaultItem(Settings.GUI_SHULKER_INSPECT_BG_ITEM.getMaterial().parseItem());
|
||||
setUseLockedCells(false);
|
||||
@ -45,7 +45,7 @@ public class GUIShulkerInspect extends Gui {
|
||||
|
||||
for (int i : fillSlots) setItem(i, getDefaultItem());
|
||||
setButton(5, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()))));
|
||||
BlockStateMeta meta = (BlockStateMeta) this.shulker.getItemMeta();
|
||||
BlockStateMeta meta = (BlockStateMeta) this.container.getItemMeta();
|
||||
ShulkerBox skulkerBox = (ShulkerBox) meta.getBlockState();
|
||||
|
||||
int slot = 9;
|
@ -55,6 +55,8 @@ public class Settings {
|
||||
public static final ConfigSetting REFRESH_COOL_DOWN = new ConfigSetting(config, "auction setting.refresh cool down", 2, "How many seconds should pass before the player can refresh the auction house again?");
|
||||
public static final ConfigSetting ALLOW_PURCHASE_IF_INVENTORY_FULL = new ConfigSetting(config, "auction setting.allow purchase with full inventory", true, "Should auction house allow players to buy items even if their", "inventory is full, if true, items will be dropped on the floor if there is no room.");
|
||||
|
||||
public static final ConfigSetting ASK_FOR_BID_CONFIRMATION = new ConfigSetting(config, "auction setting.ask for bid confirmation", true, "Should Auction House open the confirmation menu for the user to confirm", "whether they actually meant to place a bid or not?");
|
||||
|
||||
/* ===============================
|
||||
* DATABASE OPTIONS
|
||||
* ===============================*/
|
||||
@ -246,6 +248,22 @@ public class Settings {
|
||||
"&7Click to confirm your purchase"
|
||||
));
|
||||
|
||||
/* ===============================
|
||||
* CONFIRM BID GUI
|
||||
* ===============================*/
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_TITLE = new ConfigSetting(config, "gui.confirm bid.title", "&7Are you sure?");
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_NO_ITEM = new ConfigSetting(config, "gui.confirm bid.no.item", "RED_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_NO_NAME = new ConfigSetting(config, "gui.confirm bid.no.name", "&c&LCancel");
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_NO_LORE = new ConfigSetting(config, "gui.confirm bid.no.lore", Collections.singletonList(
|
||||
"&7Click to cancel your bid"
|
||||
));
|
||||
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_YES_ITEM = new ConfigSetting(config, "gui.confirm bid.yes.item", "LIME_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_YES_NAME = new ConfigSetting(config, "gui.confirm bid.yes.name", "&a&lConfirm");
|
||||
public static final ConfigSetting GUI_CONFIRM_BID_YES_LORE = new ConfigSetting(config, "gui.confirm bid.yes.lore", Collections.singletonList(
|
||||
"&7Click to confirm your bid"
|
||||
));
|
||||
|
||||
/* ===============================
|
||||
* ACTIVE AUCTION GUI
|
||||
* ===============================*/
|
||||
|
Loading…
Reference in New Issue
Block a user