#21 add cancel word to title inputs

This commit is contained in:
Kiran Hart 2022-11-25 13:57:53 -05:00
parent 6748cf3090
commit 14cd5351f3
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 8 additions and 1 deletions

View File

@ -19,10 +19,12 @@
package ca.tweetzy.auctionhouse.helpers.input;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.flight.comp.ActionBar;
import ca.tweetzy.flight.comp.Titles;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -80,6 +82,10 @@ public abstract class Input implements Listener, Runnable {
)
public void onChat(AsyncPlayerChatEvent e) {
if (e.getPlayer().equals(this.player)) {
if (ChatColor.stripColor(e.getMessage()).equals(Settings.TITLE_INPUT_CANCEL_WORD.getString())) {
e.setCancelled(true);
this.close(false);
}
this.onInput(e.getMessage());
e.setCancelled(true);

View File

@ -43,7 +43,7 @@ public abstract class TitleInput extends Input {
this.player = player;
this.title = title;
this.subTitle = subTitle;
this.actionbar = actionbar;
this.actionbar = Common.colorize(actionbar);
}
public TitleInput(@NonNull final Player player, final String title, final String subTitle) {

View File

@ -148,6 +148,7 @@ public class Settings {
public static final ConfigSetting ALLOW_PLAYERS_TO_DEFINE_AUCTION_TIME = new ConfigSetting(config, "auction setting.allow players to set auction time", false, "If true players can use -t 1 day for example to set the listing time for their item");
public static final ConfigSetting MAX_CUSTOM_DEFINED_TIME = new ConfigSetting(config, "auction setting.max custom defined time", 604800, "What should the limit on custom defined listing times be in seconds?");
public static final ConfigSetting SMART_MIN_BUY_PRICE = new ConfigSetting(config, "auction setting.smart min and buy price", false, "Will calculate buy now/min prices on a per item basis. For example, if the user states $100 and the item is in a stack of", "32, the min / buy now price will be $3200. If they provide -s or -stack in the command", "this will be ignored and the entire stack will sell for $100");
public static final ConfigSetting TITLE_INPUT_CANCEL_WORD = new ConfigSetting(config, "auction setting.title input cancel word", "cancel", "The word to be used to cancel chat inputs (users can also just click any block)");
public static final ConfigSetting USE_SEPARATE_FILTER_MENU = new ConfigSetting(config, "auction setting.use separate filter menu", false, "If true, rather than using a single filter item inside the auction menu", "it will open an entirely new menu to select the filter");
public static final ConfigSetting FILTER_ONLY_USES_WHITELIST = new ConfigSetting(config, "auction setting.filter only uses whitelist", false, "If true, auction house will ignore default filters, and only filter by the items added to the category whitelists");