blocked_items config section now supports model data. Ex: PAPER:5 means if the paper has a model data of 5 its blocked.

Took 10 minutes
This commit is contained in:
Kiran Hart 2024-09-09 14:11:06 -04:00
parent fc06ad7f44
commit f27857eaaa
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 40 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import ca.tweetzy.auctionhouse.auction.MinItemPrice;
import ca.tweetzy.auctionhouse.auction.enums.PaymentReason;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.flight.comp.enums.ServerVersion;
import ca.tweetzy.flight.nbtapi.NBT;
import ca.tweetzy.flight.utils.QuickItem;
@ -793,12 +794,26 @@ public class AuctionAPI {
return false;
}
} else {
if (Settings.BLOCKED_ITEMS.getStringList().contains(itemStack.getType().name())) {
AuctionHouse.getInstance().getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemStack.getType().name()).sendPrefixedMessage(player);
return false;
for (String item : Settings.BLOCKED_ITEMS.getStringList()) {
final String[] split = item.split(":");
if (split.length == 1) {
if (split[0].contains(itemStack.getType().name())) {
AuctionHouse.getInstance().getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemStack.getType().name()).sendPrefixedMessage(player);
return false;
}
}
if (split.length == 2 && NumberUtils.isInt(split[1]) && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) {
if (split[0].contains(itemStack.getType().name()) && itemStack.getItemMeta() != null && itemStack.getItemMeta().getCustomModelData() == Integer.parseInt(split[1])) {
AuctionHouse.getInstance().getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemStack.getType().name()).sendPrefixedMessage(player);
return false;
}
}
}
}
// Check NBT tags
for (String nbtTag : Settings.BLOCKED_NBT_TAGS.getStringList()) {
if (NBT.get(itemStack, nbt -> (boolean) nbt.hasTag(nbtTag))) {

View File

@ -31,6 +31,19 @@ import java.util.Locale;
public final class AuctionAPI implements AuctionHouseAPI {
private String replaceLastDecimal(String input) {
int lastComma = input.lastIndexOf(",00");
int lastDot = input.lastIndexOf(".00");
int lastIndex = Math.max(lastComma, lastDot);
if (lastIndex != -1) {
return input.substring(0, lastIndex) + input.substring(lastIndex + 3);
}
return input;
}
@Override
public String getNumberAsCurrency(double number, boolean hideSymbol) {
@ -48,7 +61,13 @@ public final class AuctionAPI implements AuctionHouseAPI {
decimalFormat.setDecimalFormatSymbols(symbols);
}
return currencyFormatter.format(number);
String formatted = currencyFormatter.format(number);
if (Settings.CURRENCY_STRIP_ENDING_ZEROES.getBoolean()) {
formatted = replaceLastDecimal(formatted);
}
return formatted;
}
@Override

View File

@ -49,7 +49,8 @@ public class Settings {
public static final ConfigSetting CURRENCY_FORMAT_LANGUAGE = new ConfigSetting(config, "economy.currency.format.language", "en", "An ISO 639 alpha-2 or alpha-3 language code.");
public static final ConfigSetting CURRENCY_FORMAT_COUNTRY = new ConfigSetting(config, "economy.currency.format.country", "US", "An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.");
public static final ConfigSetting CURRENCY_ABBREVIATE_NUMBERS = new ConfigSetting(config, "economy.currency.abbreviate numbers", false, "Should numbers be abbreviated?. Example: 123,000 will become 123k ");
public static final ConfigSetting CURRENCY_STRIP_ENDING_ZEROES = new ConfigSetting(config, "economy.currency.strip ending zeroes", false, "If the number ends with 00, should it be stripped. EX 123.00 becomes 123");
public static final ConfigSetting CMD_ALIAS_MAIN = new ConfigSetting(config, "command aliases.main", Arrays.asList("ah", "auctions", "auctionhouses", "ahgui", "auctiongui"), "Command aliases for the main command");
public static final ConfigSetting CMD_ALIAS_SUB_ACTIVE = new ConfigSetting(config, "command aliases.subcommands.active", Collections.singletonList("active"), "Command aliases for the active command");
public static final ConfigSetting CMD_ALIAS_SUB_ADMIN = new ConfigSetting(config, "command aliases.subcommands.admin", Collections.singletonList("admin"), "Command aliases for the admin command");