Block requests using shulkers that contain items. Closes #101

Took 7 minutes
This commit is contained in:
Kiran Hart 2024-10-07 12:11:44 -04:00
parent 1864670806
commit 9540c3ad61
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 37 additions and 0 deletions

View File

@ -35,10 +35,16 @@ import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.flight.command.AllowedExecutor;
import ca.tweetzy.flight.command.Command;
import ca.tweetzy.flight.command.ReturnType;
import ca.tweetzy.flight.comp.enums.ServerVersion;
import net.minecraft.references.Blocks;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.ShulkerBox;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.List;
@ -90,6 +96,32 @@ public class CommandRequest extends Command {
// Check for block items
if (!AuctionAPI.getInstance().meetsListingRequirements(player, originalItem)) return ReturnType.FAIL;
// check if is shulker box and if contains items
if (Settings.BLOCK_REQUEST_USING_FILLED_SHULKER.getBoolean() && ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (originalItem.getItemMeta() instanceof BlockStateMeta) {
final BlockStateMeta meta = (BlockStateMeta) originalItem.getItemMeta();
// check if shulker
if (meta.getBlockState() instanceof ShulkerBox) {
final ShulkerBox shulkerBox = (ShulkerBox) meta.getBlockState();
boolean containsItems = false;
for (ItemStack item : shulkerBox.getInventory().getContents()) {
if (item != null && item.getType() != Material.AIR) {
containsItems = true;
break;
}
}
if (containsItems) {
AuctionHouse.getInstance().getLocale().getMessage("general.general.request shulker contains items").sendPrefixedMessage(player);
return ReturnType.FAIL;
}
}
}
}
// check if at limit
if (auctionPlayer.isAtItemLimit(player)) {
AuctionHouse.getInstance().getLocale().getMessage("general.requestlimit").sendPrefixedMessage(player);

View File

@ -48,6 +48,8 @@ public class LocaleSettings {
languageNodes.put("general.notenoughitems", "&cYou do not have enough of that item!");
languageNodes.put("general.cannotbezero", "&cPlease provide a number greater than zero");
languageNodes.put("general.highrequestcount", "&cYou cannot request that many items!");
languageNodes.put("general.request shulker contains items", "&cPlease make the request using an empty shulker");
languageNodes.put("general.cantbidonown", "&cYou cannot bid on your own item!");
languageNodes.put("general.alreadyhighestbidder", "&cYou are already the highest bidder!");
languageNodes.put("general.cantbuyown", "&cYou cannot buy your own item!");

View File

@ -115,6 +115,9 @@ public class Settings {
public static final ConfigSetting OWNER_CAN_BID_OWN_ITEM = new ConfigSetting(config, "auction setting.purchase.owner can bid on own item", false, "Should the owner of an auction be able to bid on it?", "This probably should be set to false...");
public static final ConfigSetting OWNER_CAN_FULFILL_OWN_REQUEST = new ConfigSetting(config, "auction setting.purchase.owner can fulfill own request", false, "Should the owner of a request be able to fulfill it", "This probably should be set to false...");
public static final ConfigSetting MAX_REQUEST_AMOUNT = new ConfigSetting(config, "auction setting.max request amount", 64, "How much of an item should a player be able to ask for in a single request?");
public static final ConfigSetting BLOCK_REQUEST_USING_FILLED_SHULKER = new ConfigSetting(config, "auction setting.block requests using filled shulkers", true, "If false, players can request make a request using a shulker that contains items");
public static final ConfigSetting AUTO_REFRESH_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh auction pages", true, "Should auction pages auto refresh?");
public static final ConfigSetting AUTO_REFRESH_ACTIVE_AUCTION_PAGES = new ConfigSetting(config, "auction setting.auto refresh active auction pages", false, "Should the /ah active pages be auto refreshed?");
public static final ConfigSetting INCREASE_TIME_ON_BID = new ConfigSetting(config, "auction setting.increase time on bid", true, "Should the remaining time be increased when a bid is placed?");