mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-25 05:55:13 +01:00
2.16.0 - filter disable and search fix
This commit is contained in:
parent
f4ace15320
commit
2993212258
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.15.1</version>
|
||||
<version>2.16.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -195,6 +195,7 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
public void onConfigReload() {
|
||||
Settings.setup();
|
||||
setLocale(Settings.LANG.getString());
|
||||
LocaleSettings.setup();
|
||||
this.commandManager.setSyntaxErrorMessage(TextUtils.formatText(getLocale().getMessage("commands.invalid_syntax").getMessage().split("\n")));
|
||||
this.commandManager.setNoPermsMessage(TextUtils.formatText(getLocale().getMessage("commands.no_permission").getMessage()));
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
package ca.tweetzy.auctionhouse.api;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.ItemUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -280,9 +278,9 @@ public class AuctionAPI {
|
||||
* @return whether the keyword is found
|
||||
*/
|
||||
public boolean match(String pattern, String sentence) {
|
||||
Pattern patt = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
|
||||
Pattern patt = Pattern.compile(ChatColor.stripColor(pattern), Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = patt.matcher(sentence);
|
||||
return matcher.matches();
|
||||
return matcher.find();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ca.tweetzy.auctionhouse.auction;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -3,7 +3,6 @@ package ca.tweetzy.auctionhouse.auction;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.ServerVersion;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import lombok.Getter;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ca.tweetzy.auctionhouse.auction;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -10,25 +11,27 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
*/
|
||||
public enum AuctionItemCategory {
|
||||
|
||||
ALL("All", false),
|
||||
FOOD("Food", true),
|
||||
ARMOR("Armor", true),
|
||||
BLOCKS("Blocks", true),
|
||||
TOOLS("Tools", true),
|
||||
WEAPONS("Weapons", true),
|
||||
SPAWNERS("Spawners", true),
|
||||
ENCHANTS("Enchants", true),
|
||||
MISC("Misc", true),
|
||||
SEARCH("Search", false),
|
||||
SELF("Self", false);
|
||||
ALL("All", false, Settings.ALL_FILTER_ENABLED.getBoolean()),
|
||||
FOOD("Food", true, Settings.FOOD_FILTER_ENABLED.getBoolean()),
|
||||
ARMOR("Armor", true, Settings.ARMOR_FILTER_ENABLED.getBoolean()),
|
||||
BLOCKS("Blocks", true, Settings.BLOCKS_FILTER_ENABLED.getBoolean()),
|
||||
TOOLS("Tools", true, Settings.TOOLS_FILTER_ENABLED.getBoolean()),
|
||||
WEAPONS("Weapons", true, Settings.WEAPONS_FILTER_ENABLED.getBoolean()),
|
||||
SPAWNERS("Spawners", true, Settings.SPAWNERS_FILTER_ENABLED.getBoolean()),
|
||||
ENCHANTS("Enchants", true, Settings.ENCHANTS_FILTER_ENABLED.getBoolean()),
|
||||
MISC("Misc", true, Settings.MISC_FILTER_ENABLED.getBoolean()),
|
||||
SEARCH("Search", false, Settings.SEARCH_FILTER_ENABLED.getBoolean()),
|
||||
SELF("Self", false, Settings.SELF_FILTER_ENABLED.getBoolean());
|
||||
|
||||
|
||||
private final String type;
|
||||
private final boolean whitelistAllowed;
|
||||
private final boolean enabled;
|
||||
|
||||
AuctionItemCategory(String type, boolean whitelistAllowed) {
|
||||
AuctionItemCategory(String type, boolean whitelistAllowed, boolean enabled) {
|
||||
this.type = type;
|
||||
this.whitelistAllowed = whitelistAllowed;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
@ -39,6 +42,10 @@ public enum AuctionItemCategory {
|
||||
return whitelistAllowed;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String getTranslatedType() {
|
||||
switch (this) {
|
||||
case ALL:
|
||||
@ -68,6 +75,12 @@ public enum AuctionItemCategory {
|
||||
}
|
||||
|
||||
public AuctionItemCategory next() {
|
||||
return values()[(this.ordinal() + 1) % values().length];
|
||||
int currentIndex = this.ordinal();
|
||||
int nextIndex = currentIndex + 1;
|
||||
while (!values()[nextIndex %= values().length].isEnabled()) {
|
||||
nextIndex++;
|
||||
}
|
||||
|
||||
return values()[nextIndex];
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.commands.AbstractCommand;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.items.ItemUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ca.tweetzy.auctionhouse.guis;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionStackType;
|
||||
|
@ -110,11 +110,13 @@ public class GUIAuctionHouse extends Gui {
|
||||
}
|
||||
|
||||
private boolean checkSearchCriteria(String phrase, AuctionItem item) {
|
||||
return AuctionAPI.getInstance().match(phrase, item.getItemName()) ||
|
||||
ItemStack stack = AuctionAPI.getInstance().deserializeItem(item.getRawItem());
|
||||
return AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemName(stack)) ||
|
||||
AuctionAPI.getInstance().match(phrase, item.getCategory().getTranslatedType()) ||
|
||||
AuctionAPI.getInstance().match(phrase, stack.getType().name()) ||
|
||||
AuctionAPI.getInstance().match(phrase, Bukkit.getOfflinePlayer(item.getOwner()).getName()) ||
|
||||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemLore(AuctionAPI.getInstance().deserializeItem(item.getRawItem()))) ||
|
||||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemEnchantments(AuctionAPI.getInstance().deserializeItem(item.getRawItem())));
|
||||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemLore(stack)) ||
|
||||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemEnchantments(stack));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4,7 +4,6 @@ import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionFilterItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItemCategory;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XSound;
|
||||
import ca.tweetzy.core.gui.Gui;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.TItemBuilder;
|
||||
|
@ -5,7 +5,6 @@ import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.api.UpdateChecker;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
|
||||
import ca.tweetzy.core.compatibility.CompatibleHand;
|
||||
import ca.tweetzy.core.compatibility.ServerVersion;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
|
@ -2,7 +2,6 @@ package ca.tweetzy.auctionhouse.managers;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionFilterItem;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionItem;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -65,6 +65,18 @@ public class Settings {
|
||||
|
||||
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 ALL_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.all", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting FOOD_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.food", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting ARMOR_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.armor", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting BLOCKS_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.blocks", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting TOOLS_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.tools", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting WEAPONS_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.weapons", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting SPAWNERS_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.spawners", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting ENCHANTS_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.enchants", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting MISC_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.misc", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting SEARCH_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.search", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting SELF_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.self", true, "Should this filter be enabled?");
|
||||
|
||||
public static final ConfigSetting ALLOW_ITEM_BUNDLES = new ConfigSetting(config, "auction setting.bundles.enabled", true, "If true, players can use -b in the sell command to bundle all similar items into a single item.");
|
||||
public static final ConfigSetting ITEM_BUNDLE_ITEM = new ConfigSetting(config, "auction setting.bundles.item", XMaterial.GOLD_BLOCK.name());
|
||||
public static final ConfigSetting ITEM_BUNDLE_NAME = new ConfigSetting(config, "auction setting.bundles.name", "%item_name% &7Bundle");
|
||||
|
Loading…
Reference in New Issue
Block a user