From 6748cf3090041e295c5f7a8b61f654cdd9e8b7d3 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Fri, 25 Nov 2022 13:44:19 -0500 Subject: [PATCH] #21 add option to use %remaining_days/hours/minutes/seconds% within clock (listing time) lore in sell menus --- .../auctionhouse/guis/sell/GUISellAuction.java | 11 ++++++++++- .../ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java | 11 ++++++++++- .../ca/tweetzy/auctionhouse/helpers/input/Input.java | 1 + .../ca/tweetzy/auctionhouse/settings/Settings.java | 4 ++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java index 5a34972..5ddba52 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java @@ -77,10 +77,19 @@ public final class GUISellAuction extends AbstractPlaceholderGui { reset(); if (Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean()) { + + final long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.listingTime); + setButton(3, 1, QuickItem .of(Objects.requireNonNull(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_ITEM.getMaterial().parseItem())) .name(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_NAME.getString()) - .lore(Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_LORE.getStringList()).make(), click -> { + .lore(Replacer.replaceVariables( + Settings.GUI_SELL_AUCTION_ITEM_ITEMS_TIME_LORE.getStringList(), + "remaining_days", times[0], + "remaining_hours", times[1], + "remaining_minutes", times[2], + "remaining_seconds", times[3] + )).make(), click -> { click.gui.exit(); new TitleInput(click.player, AuctionHouse.getInstance().getLocale().getMessage("titles.listing time.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.listing time.subtitle").getMessage()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java index 9e3f8f7..86a2213 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java @@ -73,10 +73,19 @@ public final class GUISellBin extends AbstractPlaceholderGui { reset(); if (Settings.ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME.getBoolean()) { + + final long[] times = AuctionAPI.getInstance().getRemainingTimeValues(this.listingTime); + setButton(3, 1, QuickItem .of(Objects.requireNonNull(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_ITEM.getMaterial().parseItem())) .name(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_NAME.getString()) - .lore(Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_LORE.getStringList()).make(), click -> { + .lore(Replacer.replaceVariables( + Settings.GUI_SELL_BIN_ITEM_ITEMS_TIME_LORE.getStringList(), + "remaining_days", times[0], + "remaining_hours", times[1], + "remaining_minutes", times[2], + "remaining_seconds", times[3] + )).make(), click -> { click.gui.exit(); new TitleInput(click.player, AuctionHouse.getInstance().getLocale().getMessage("titles.listing time.title").getMessage(), AuctionHouse.getInstance().getLocale().getMessage("titles.listing time.subtitle").getMessage()) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/helpers/input/Input.java b/src/main/java/ca/tweetzy/auctionhouse/helpers/input/Input.java index eedd187..03b3ff7 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/helpers/input/Input.java +++ b/src/main/java/ca/tweetzy/auctionhouse/helpers/input/Input.java @@ -80,6 +80,7 @@ public abstract class Input implements Listener, Runnable { ) public void onChat(AsyncPlayerChatEvent e) { if (e.getPlayer().equals(this.player)) { + this.onInput(e.getMessage()); e.setCancelled(true); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java index 8a73f0c..83be3d9 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java @@ -930,6 +930,8 @@ public class Settings { public static final ConfigSetting GUI_SELL_BIN_ITEM_ITEMS_TIME_ITEM = new ConfigSetting(config, "gui.sell bin item.items.time.item", XMaterial.CLOCK.name()); public static final ConfigSetting GUI_SELL_BIN_ITEM_ITEMS_TIME_NAME = new ConfigSetting(config, "gui.sell bin item.items.time.name", "&e&lListing Time"); public static final ConfigSetting GUI_SELL_BIN_ITEM_ITEMS_TIME_LORE = new ConfigSetting(config, "gui.sell bin item.items.time.lore", Arrays.asList( + "", + "&eCurrent Time: &b%remaining_days%&fd &b%remaining_hours%&fh &b%remaining_minutes%&fm &b%remaining_seconds%&Fs", "", "&7Click to edit the listing time" )); @@ -972,6 +974,8 @@ public class Settings { public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_TIME_ITEM = new ConfigSetting(config, "gui.sell auction item.items.time.item", XMaterial.CLOCK.name()); public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_TIME_NAME = new ConfigSetting(config, "gui.sell auction item.items.time.name", "&e&lListing Time"); public static final ConfigSetting GUI_SELL_AUCTION_ITEM_ITEMS_TIME_LORE = new ConfigSetting(config, "gui.sell auction item.items.time.lore", Arrays.asList( + "", + "&eCurrent Time: &b%remaining_days%&fd &b%remaining_hours%&fh &b%remaining_minutes%&fm &b%remaining_seconds%&Fs", "", "&7Click to edit the listing time" ));