diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AuctionItemCategory.java b/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AuctionItemCategory.java index a51509d..e8cd142 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AuctionItemCategory.java +++ b/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AuctionItemCategory.java @@ -140,13 +140,29 @@ public enum AuctionItemCategory { return getType(); } +// public AuctionItemCategory next() { +// int currentIndex = this.ordinal(); +// int nextIndex = currentIndex + 1; +// while (!values()[nextIndex %= values().length].isEnabled()) { +// nextIndex++; +// } +// +// return values()[nextIndex]; +// } + public AuctionItemCategory next() { int currentIndex = this.ordinal(); - int nextIndex = currentIndex + 1; - while (!values()[nextIndex %= values().length].isEnabled()) { - nextIndex++; + int nextIndex = currentIndex; + int totalCategories = values().length; + + for (int i = 1; i <= totalCategories; i++) { + nextIndex = (currentIndex + i) % totalCategories; + if (values()[nextIndex].isEnabled()) { + return values()[nextIndex]; + } } - return values()[nextIndex]; + // If no enabled categories are found, return the current category + return this; } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java index 2daae76..3392674 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java @@ -426,8 +426,9 @@ public final class CommandSell extends Command { AuctionHouse.getAuctionPlayerManager().processSell(player); if (listingResult != ListingResult.SUCCESS) { -// PlayerUtils.giveItem(player, auction.getCleanItem()); + PlayerUtils.giveItem(player, auction.getCleanItem()); auctionPlayer.setItemBeingListed(null); + AuctionHouse.newChain().sync(player::closeInventory).execute(); return; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java index 14b7cac..c43aa88 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java @@ -59,7 +59,7 @@ public final class GUIListingConfirm extends AuctionBaseGUI { }); setOnClose(close -> { - final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(close.player.getUniqueId()); + final AuctionPlayer auctionPlayer = AuctionHouse.getAuctionPlayerManager().getPlayer(close.player.getUniqueId()); if (!this.resulted.contains(close.player.getUniqueId())) { if (auctionPlayer.getItemBeingListed() != null) { @@ -73,7 +73,7 @@ public final class GUIListingConfirm extends AuctionBaseGUI { } close.player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); - AuctionHouse.getInstance().getAuctionPlayerManager().processSell(close.player); + AuctionHouse.getAuctionPlayerManager().processSell(close.player); }); draw(); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java index 2efdbd2..5d75307 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/core/GUIAuctionHouse.java @@ -665,7 +665,7 @@ public final class GUIAuctionHouse extends AuctionUpdatingPagedGUI