diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionPlayer.java b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionPlayer.java index 1597c9f..a836904 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionPlayer.java +++ b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionPlayer.java @@ -1,7 +1,9 @@ package ca.tweetzy.auctionhouse.auction; import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.auctionhouse.settings.Settings; +import ca.tweetzy.core.utils.TimeUtils; import lombok.Getter; import lombok.Setter; import org.bukkit.entity.Player; @@ -26,12 +28,29 @@ public class AuctionPlayer { private AuctionSortType auctionSortType; private String currentSearchPhrase; private boolean showListingInfo = true; + private long lastListedItem = -1; public AuctionPlayer(Player player) { this.player = player; resetFilter(); } + + public boolean canListItem() { + if (Settings.LIST_ITEM_DELAY.getInt() == -1) { + return true; + } + + if (this.lastListedItem == -1 || System.currentTimeMillis() >= this.lastListedItem) { + this.lastListedItem = System.currentTimeMillis() + 1000L * Settings.LIST_ITEM_DELAY.getInt(); + return true; + } + + AuctionHouse.getInstance().getLocale().getMessage("general.wait_to_list").processPlaceholder("time", (this.lastListedItem - System.currentTimeMillis()) / 1000).sendPrefixedMessage(this.player); + + return false; + } + public List getItems(boolean getExpired) { List items = new ArrayList<>(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java index a40c1e8..b5e7928 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java @@ -54,6 +54,10 @@ public class CommandSell extends AbstractCommand { return ReturnType.FAILURE; } + if (!auctionPlayer.canListItem()) { + return ReturnType.FAILURE; + } + // open the sell menu if its 0; if (args.length == 0) { if (!Settings.ALLOW_USAGE_OF_SELL_GUI.getBoolean()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionPlayerManager.java b/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionPlayerManager.java index 1803564..1303ab7 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionPlayerManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionPlayerManager.java @@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse.managers; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.settings.Settings; import lombok.Getter; +import lombok.Setter; import org.bukkit.inventory.ItemStack; import java.util.HashMap; diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java index cc2a688..d8e5f62 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java @@ -44,6 +44,7 @@ public class LocaleSettings { languageNodes.put("general.toggled listing.on", "&aYou turned on listing messages"); languageNodes.put("general.toggled listing.off", "&cYou turned off listing messages"); languageNodes.put("general.bought_item", "&aYou bought &fx%amount% %item%&a for &a$%price%"); + languageNodes.put("general.wait_to_list", "&cPlease wait &4%time%&cs before listing another item"); languageNodes.put("pricing.minbaseprice", "&cThe minimum base price must be &a$%price%"); diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java index 348fa50..bcb2095 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java @@ -69,6 +69,7 @@ public class Settings { public static final ConfigSetting FORCE_AUCTION_USAGE = new ConfigSetting(config, "auction setting.force auction usage", false, "If enabled, all items sold on the auction house must be an auction (biddable) items"); public static final ConfigSetting ALLOW_INDIVIDUAL_ITEM_CLAIM = new ConfigSetting(config, "auction setting.allow individual item claim", true, "If enabled, you will be able to click individual items from the expiration menu to claim them back. Otherwise you will have to use the claim all button"); public static final ConfigSetting FORCE_CUSTOM_BID_AMOUNT = new ConfigSetting(config, "auction setting.force custom bid amount", false, "If enabled, the bid increment line on auction items will be hidden, bid increment values will be ignored, and when you go to bid on an item, it will ask you to enter a custom amount."); + public static final ConfigSetting LIST_ITEM_DELAY = new ConfigSetting(config, "auction setting.list item delay", -1, "If not set to -1 (disabled) how many seconds must a player wait to list another item after listing 1?"); public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on bid items", true, "Should Auction House ask the user if they want to cancel the item?"); public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_NON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on non bid items", false, "Should Auction House ask the user if they want to cancel the item?");