mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-02 17:01:23 +01:00
2.30.0
This commit is contained in:
parent
cb59797d18
commit
c86bf6fc05
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.29.0</version>
|
||||
<version>2.30.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -9,16 +9,14 @@ import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.gui.Gui;
|
||||
import ca.tweetzy.core.gui.events.GuiClickEvent;
|
||||
import ca.tweetzy.core.input.ChatPrompt;
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@ -38,9 +36,10 @@ public class GUISellItem extends Gui {
|
||||
private double bidIncrementPrice;
|
||||
private boolean isBiddingItem;
|
||||
private boolean isAllowingBuyNow;
|
||||
private int auctionTime;
|
||||
|
||||
|
||||
public GUISellItem(AuctionPlayer auctionPlayer, ItemStack itemToBeListed, double buyNowPrice, double bidStartPrice, double bidIncrementPrice, boolean isBiddingItem, boolean isAllowingBuyNow) {
|
||||
public GUISellItem(AuctionPlayer auctionPlayer, ItemStack itemToBeListed, double buyNowPrice, double bidStartPrice, double bidIncrementPrice, boolean isBiddingItem, boolean isAllowingBuyNow, int auctionTime) {
|
||||
this.auctionPlayer = auctionPlayer;
|
||||
this.itemToBeListed = itemToBeListed;
|
||||
this.buyNowPrice = buyNowPrice;
|
||||
@ -48,12 +47,13 @@ public class GUISellItem extends Gui {
|
||||
this.bidIncrementPrice = bidIncrementPrice;
|
||||
this.isBiddingItem = isBiddingItem;
|
||||
this.isAllowingBuyNow = isAllowingBuyNow;
|
||||
this.auctionTime = auctionTime;
|
||||
setTitle(TextUtils.formatText(Settings.GUI_SELL_TITLE.getString()));
|
||||
setDefaultItem(Settings.GUI_SELL_BG_ITEM.getMaterial().parseItem());
|
||||
setUseLockedCells(true);
|
||||
setAllowDrops(false);
|
||||
setAllowClose(false);
|
||||
setRows(5);
|
||||
setRows(Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean() ? 6 : 5);
|
||||
|
||||
setOnOpen(open -> {
|
||||
// Check if they are already using a sell gui
|
||||
@ -82,7 +82,7 @@ public class GUISellItem extends Gui {
|
||||
ItemStack toGiveBack = AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().get(close.player.getUniqueId());
|
||||
PlayerUtils.giveItem(close.player, toGiveBack); // this could give them air
|
||||
|
||||
try {
|
||||
try {
|
||||
if (toGiveBack.getType() == XMaterial.AIR.parseMaterial()) {
|
||||
if (getItem(1, 4) != null && getItem(1, 4).getType() != XMaterial.AIR.parseMaterial()) {
|
||||
PlayerUtils.giveItem(close.player, getItem(1, 4));
|
||||
@ -104,30 +104,64 @@ public class GUISellItem extends Gui {
|
||||
}
|
||||
|
||||
setUnlocked(1, 4);
|
||||
setUnlockedRange(45, 89);
|
||||
setUnlockedRange(54, 89);
|
||||
draw();
|
||||
}
|
||||
|
||||
public GUISellItem(AuctionPlayer auctionPlayer, ItemStack itemToBeListed) {
|
||||
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(), false, true);
|
||||
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(), false, true, auctionPlayer.getAllowedSellTime());
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
reset();
|
||||
|
||||
// the draw item that is being listed
|
||||
setButton(1, 4, this.itemToBeListed, e -> {
|
||||
if (e.clickType == ClickType.RIGHT || e.clickType == ClickType.NUMBER_KEY) e.event.setCancelled(true);
|
||||
// Is the user selling with an item in hand?
|
||||
if (AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().containsKey(e.player.getUniqueId())) {
|
||||
if (AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().get(e.player.getUniqueId()).getType() != XMaterial.AIR.parseMaterial()) {
|
||||
e.event.setCancelled(true);
|
||||
}
|
||||
setButton(1, 4, this.itemToBeListed, e -> {
|
||||
if (e.clickType == ClickType.RIGHT || e.clickType == ClickType.NUMBER_KEY) e.event.setCancelled(true);
|
||||
// Is the user selling with an item in hand?
|
||||
if (AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().containsKey(e.player.getUniqueId())) {
|
||||
if (AuctionHouse.getInstance().getAuctionPlayerManager().getSellHolding().get(e.player.getUniqueId()).getType() != XMaterial.AIR.parseMaterial()) {
|
||||
e.event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.itemToBeListed = e.clickedItem;
|
||||
this.itemToBeListed = e.clickedItem;
|
||||
});
|
||||
|
||||
if (Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean()) {
|
||||
long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.auctionTime);
|
||||
|
||||
setButton(4, 2, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_LIST_TIME_ITEM.getString(), Settings.GUI_SELL_ITEMS_LIST_TIME_NAME.getString(), Settings.GUI_SELL_ITEMS_LIST_TIME_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%remaining_days%", times[0]);
|
||||
put("%remaining_hours%", times[1]);
|
||||
put("%remaining_minutes%", times[2]);
|
||||
put("%remaining_seconds%", times[3]);
|
||||
}}), ClickType.LEFT, e -> {
|
||||
e.gui.close();
|
||||
PlayerChatInput.PlayerChatInputBuilder<Long> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> {
|
||||
String[] parts = str.split(" ");
|
||||
if (parts.length == 2) {
|
||||
if (NumberUtils.isInt(parts[0]) && Arrays.asList("second", "minute", "hour", "day", "week", "month", "year").contains(parts[1].toLowerCase())) {
|
||||
return AuctionAPI.toTicks(str) <= Settings.MAX_CUSTOM_DEFINED_TIME.getInt();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter listing time").getMessage()));
|
||||
builder.invalidInputMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter valid listing time").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> reopen(e));
|
||||
builder.setValue((p, value) -> AuctionAPI.toTicks(value));
|
||||
builder.onFinish((p, value) -> {
|
||||
this.auctionTime = value.intValue();
|
||||
reopen(e);
|
||||
});
|
||||
|
||||
PlayerChatInput<Long> input = builder.build();
|
||||
input.start();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && this.isAllowingBuyNow) {
|
||||
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>() {{
|
||||
@ -231,7 +265,7 @@ public class GUISellItem extends Gui {
|
||||
e.player,
|
||||
this.itemToBeListed.clone(),
|
||||
this.itemToBeListed.clone(),
|
||||
this.auctionPlayer.getAllowedSellTime(),
|
||||
this.auctionTime,
|
||||
this.isBiddingItem && !isAllowingBuyNow || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? -1 : buyNowPrice,
|
||||
this.isBiddingItem ? bidStartPrice : 0,
|
||||
Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean() ? 1 : this.isBiddingItem ? bidIncrementPrice : 0,
|
||||
@ -259,7 +293,7 @@ public class GUISellItem extends Gui {
|
||||
}
|
||||
|
||||
private void reopen(GuiClickEvent e) {
|
||||
e.manager.showGUI(e.player, new GUISellItem(this.auctionPlayer, this.itemToBeListed, this.buyNowPrice, this.bidStartPrice, this.bidIncrementPrice, this.isBiddingItem, this.isAllowingBuyNow));
|
||||
e.manager.showGUI(e.player, new GUISellItem(this.auctionPlayer, this.itemToBeListed, this.buyNowPrice, this.bidStartPrice, this.bidIncrementPrice, this.isBiddingItem, this.isAllowingBuyNow, this.auctionTime));
|
||||
}
|
||||
|
||||
private void setTheItemToBeListed() {
|
||||
|
@ -62,6 +62,8 @@ public class LocaleSettings {
|
||||
languageNodes.put("prompts.enter new bid increment", "&aPlease enter the new bid increment in chat:");
|
||||
languageNodes.put("prompts.enter bid amount", "&aPlease enter bid amount in chat:");
|
||||
languageNodes.put("prompts.enter valid bid amount", "&cBid either too low or too high");
|
||||
languageNodes.put("prompts.enter listing time", "&aPlease enter listing time (ex. 1 day):");
|
||||
languageNodes.put("prompts.enter valid listing time", "&cPlease enter a valid listing time.");
|
||||
|
||||
languageNodes.put("transaction.sale_type.bid_won", "Won Auction");
|
||||
languageNodes.put("transaction.sale_type.immediate_buy", "Bought Immediately");
|
||||
|
@ -677,6 +677,13 @@ public class Settings {
|
||||
"&7Click to edit the price"
|
||||
));
|
||||
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_LIST_TIME_ITEM = new ConfigSetting(config, "gui.sell.items.list time.item", XMaterial.CLOCK.name());
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_LIST_TIME_NAME = new ConfigSetting(config, "gui.sell.items.list time.name", "&e&lListing Time");
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_LIST_TIME_LORE = new ConfigSetting(config, "gui.sell.items.list time.lore", Arrays.asList(
|
||||
"&7The listing time is&f: &b%remaining_days%&fd &b%remaining_hours%&fh &b%remaining_minutes%&fm &b%remaining_seconds%&fs",
|
||||
"&7Click to edit the listing time"
|
||||
));
|
||||
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_CONFIRM_LISTING_ITEM = new ConfigSetting(config, "gui.sell.items.confirm listing.item", XMaterial.LIME_STAINED_GLASS_PANE.name());
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_CONFIRM_LISTING_NAME = new ConfigSetting(config, "gui.sell.items.confirm listing.name", "&a&lConfirm Listing");
|
||||
public static final ConfigSetting GUI_SELL_ITEMS_CONFIRM_LISTING_LORE = new ConfigSetting(config, "gui.sell.items.confirm listing.lore", Collections.singletonList("&7Click to confirm the listing of this item."));
|
||||
|
Loading…
Reference in New Issue
Block a user