From f124de2d6b666fa687b39e47203757146ab09bf0 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Tue, 20 Jun 2023 18:42:46 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9D=8C=20remove=20"middleware"=20checks=20fo?= =?UTF-8?q?r=20some=20admin=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 7 minutes --- .../tweetzy/auctionhouse/commands/CommandBan.java | 2 +- .../auctionhouse/commands/CommandFilter.java | 2 +- .../auctionhouse/commands/CommandMarkChest.java | 2 +- .../auctionhouse/commands/CommandMinPrice.java | 2 +- .../tweetzy/auctionhouse/helpers/BundleUtil.java | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java index 859683d..ef35321 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandBan.java @@ -51,7 +51,7 @@ public class CommandBan extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { Player player = (Player) sender; - if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; +// if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java index 5615bcd..de4e536 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandFilter.java @@ -50,7 +50,7 @@ public class CommandFilter extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; - if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; +// if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java index b7dc099..981ff05 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMarkChest.java @@ -48,7 +48,7 @@ public final class CommandMarkChest extends AbstractCommand { if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14)) return ReturnType.FAILURE; final Player player = (Player) sender; - if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; +// if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; final Block targetBlock = player.getTargetBlock(null, 10); if (targetBlock.getType() != XMaterial.CHEST.parseMaterial()) return ReturnType.FAILURE; diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java index d0a09e4..793169c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandMinPrice.java @@ -48,7 +48,7 @@ public class CommandMinPrice extends AbstractCommand { @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; - if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; +// if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; final AuctionHouse instance = AuctionHouse.getInstance(); if (args.length == 0) { diff --git a/src/main/java/ca/tweetzy/auctionhouse/helpers/BundleUtil.java b/src/main/java/ca/tweetzy/auctionhouse/helpers/BundleUtil.java index c086e9c..97961bf 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/helpers/BundleUtil.java +++ b/src/main/java/ca/tweetzy/auctionhouse/helpers/BundleUtil.java @@ -18,6 +18,7 @@ package ca.tweetzy.auctionhouse.helpers; +import ca.tweetzy.auctionhouse.api.AuctionAPI; import ca.tweetzy.core.compatibility.XMaterial; import de.tr7zw.changeme.nbtapi.NBT; import lombok.NonNull; @@ -36,6 +37,20 @@ public final class BundleUtil { } public List extractBundleItems(@NonNull final ItemStack itemStack) { + final List items = new ArrayList<>(); + + final int totalBundledItems = NBT.get(itemStack, nbt -> nbt.getInteger("AuctionBundleItem")); + + for (int i = 0; i < totalBundledItems; i++) { + int finalI = i; + if (NBT.get(itemStack, nbt -> nbt.hasTag("AuctionBundleItem-" + finalI))) + items.add(AuctionAPI.getInstance().deserializeItem(NBT.get(itemStack, nbt -> nbt.getByteArray("AuctionBundleItem-" + finalI)))); + } + + + if (!items.isEmpty()) + return items; + final ItemStack[] bundledItems = NBT.get(itemStack, nbt -> nbt.getItemStackArray("AuctionBundleItems")); return new ArrayList<>(Arrays.asList(bundledItems)); }