mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-18 19:41:19 +01:00
implement meetsListingRequirements into sell command and bundle creation
Took 1 minute
This commit is contained in:
parent
2258672bf1
commit
5160de0f29
@ -40,7 +40,6 @@ import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -48,7 +47,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -108,44 +106,44 @@ public final class CommandSell extends AbstractCommand {
|
||||
}
|
||||
|
||||
// Check for block items
|
||||
//
|
||||
// if (Settings.MAKE_BLOCKED_ITEMS_A_WHITELIST.getBoolean()) {
|
||||
// if (!Settings.BLOCKED_ITEMS.getStringList().contains(itemToSell.getType().name())) {
|
||||
// instance.getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemToSell.getType().name()).sendPrefixedMessage(player);
|
||||
// return ReturnType.FAILURE;
|
||||
// }
|
||||
// } else {
|
||||
// if (Settings.BLOCKED_ITEMS.getStringList().contains(itemToSell.getType().name())) {
|
||||
// instance.getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemToSell.getType().name()).sendPrefixedMessage(player);
|
||||
// return ReturnType.FAILURE;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean blocked = false;
|
||||
//
|
||||
// String itemName = ChatColor.stripColor(AuctionAPI.getInstance().getItemName(itemToSell).toLowerCase());
|
||||
// List<String> itemLore = AuctionAPI.getInstance().getItemLore(itemToSell).stream().map(line -> ChatColor.stripColor(line.toLowerCase())).collect(Collectors.toList());
|
||||
//
|
||||
// // Check for blocked names and lore
|
||||
// for (String s : Settings.BLOCKED_ITEM_NAMES.getStringList()) {
|
||||
// if (AuctionAPI.getInstance().match(s, itemName)) {
|
||||
// instance.getLocale().getMessage("general.blockedname").sendPrefixedMessage(player);
|
||||
// blocked = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!itemLore.isEmpty() && !blocked) {
|
||||
// for (String s : Settings.BLOCKED_ITEM_LORES.getStringList()) {
|
||||
// for (String line : itemLore) {
|
||||
// if (AuctionAPI.getInstance().match(s, line)) {
|
||||
// instance.getLocale().getMessage("general.blockedlore").sendPrefixedMessage(player);
|
||||
// blocked = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (Settings.MAKE_BLOCKED_ITEMS_A_WHITELIST.getBoolean()) {
|
||||
if (!Settings.BLOCKED_ITEMS.getStringList().contains(itemToSell.getType().name())) {
|
||||
instance.getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemToSell.getType().name()).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
} else {
|
||||
if (Settings.BLOCKED_ITEMS.getStringList().contains(itemToSell.getType().name())) {
|
||||
instance.getLocale().getMessage("general.blockeditem").processPlaceholder("item", itemToSell.getType().name()).sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
boolean blocked = false;
|
||||
|
||||
String itemName = ChatColor.stripColor(AuctionAPI.getInstance().getItemName(itemToSell).toLowerCase());
|
||||
List<String> itemLore = AuctionAPI.getInstance().getItemLore(itemToSell).stream().map(line -> ChatColor.stripColor(line.toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
// Check for blocked names and lore
|
||||
for (String s : Settings.BLOCKED_ITEM_NAMES.getStringList()) {
|
||||
if (AuctionAPI.getInstance().match(s, itemName)) {
|
||||
instance.getLocale().getMessage("general.blockedname").sendPrefixedMessage(player);
|
||||
blocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemLore.isEmpty() && !blocked) {
|
||||
for (String s : Settings.BLOCKED_ITEM_LORES.getStringList()) {
|
||||
for (String line : itemLore) {
|
||||
if (AuctionAPI.getInstance().match(s, line)) {
|
||||
instance.getLocale().getMessage("general.blockedlore").sendPrefixedMessage(player);
|
||||
blocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blocked) return ReturnType.FAILURE;
|
||||
if (!AuctionAPI.getInstance().meetsListingRequirements(player, itemToSell)) return ReturnType.FAILURE;
|
||||
|
||||
// get the max allowed time for this player.
|
||||
int allowedTime = 0;
|
||||
|
@ -31,12 +31,10 @@ import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.nms.NBTEditor;
|
||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The current file has been created by Kiran Hart
|
||||
@ -80,48 +78,14 @@ public final class GUIBundleCreation extends AbstractPlaceholderGui {
|
||||
final ItemStack item = getItem(i);
|
||||
if (item == null || item.getType() == CompMaterial.AIR.parseMaterial()) continue;
|
||||
|
||||
if (Settings.MAKE_BLOCKED_ITEMS_A_WHITELIST.getBoolean()) {
|
||||
if (!Settings.BLOCKED_ITEMS.getStringList().contains(item.getType().name())) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.blockeditem").processPlaceholder("item", item.getType().name()).sendPrefixedMessage(e.player);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (Settings.BLOCKED_ITEMS.getStringList().contains(item.getType().name())) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.blockeditem").processPlaceholder("item", item.getType().name()).sendPrefixedMessage(e.player);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean blocked = false;
|
||||
|
||||
String itemName = ChatColor.stripColor(AuctionAPI.getInstance().getItemName(item).toLowerCase());
|
||||
List<String> itemLore = AuctionAPI.getInstance().getItemLore(item).stream().map(line -> ChatColor.stripColor(line.toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
// Check for blocked names and lore
|
||||
for (String s : Settings.BLOCKED_ITEM_NAMES.getStringList()) {
|
||||
if (AuctionAPI.getInstance().match(s, itemName)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.blockedname").sendPrefixedMessage(e.player);
|
||||
blocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemLore.isEmpty() && !blocked) {
|
||||
for (String s : Settings.BLOCKED_ITEM_LORES.getStringList()) {
|
||||
for (String line : itemLore) {
|
||||
if (AuctionAPI.getInstance().match(s, line)) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.blockedlore").sendPrefixedMessage(e.player);
|
||||
blocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean meetsListingRequirements = AuctionAPI.getInstance().meetsListingRequirements(player, item);
|
||||
|
||||
if (NBTEditor.contains(item, "AuctionBundleItem")) {
|
||||
blocked = true;
|
||||
meetsListingRequirements = false;
|
||||
containsBundle = true;
|
||||
}
|
||||
|
||||
if (blocked) continue;
|
||||
if (!meetsListingRequirements) continue;
|
||||
|
||||
if (firstItem == null)
|
||||
firstItem = item;
|
||||
|
Loading…
Reference in New Issue
Block a user