From 8ed55895fc8469e22e3ae65bf450f3af794d2545 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sun, 24 Mar 2024 17:59:31 +0100 Subject: REFORMAT WHOLE FILE THE SEQUEL --- .../skyblock/auction/AuctionBrowserScreen.java | 53 ++++++++++++---------- .../skyblock/auction/AuctionViewScreen.java | 15 +++--- .../skyblocker/skyblock/auction/EditBidPopup.java | 2 +- 3 files changed, 39 insertions(+), 31 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 8e0c695b..6d87515d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -91,8 +91,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) - .position(x + 98, y+4) + addDrawableChild(new ButtonWidget.Builder(Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + 98, y + 4) .size(12, 12) .build()); @@ -132,9 +132,9 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI= handler.getRows()*9) return; + if (slotId >= handler.getRows() * 9) return; super.onMouseClick(slot, slotId, button, actionType); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (isWaitingForServer) return super.mouseClicked(mouseX, mouseY, button); - if (onScrollbarTop((int)mouseX, (int) mouseY) && prevPageVisible) { + if (onScrollbarTop((int) mouseX, (int) mouseY) && prevPageVisible) { clickSlot(PREV_PAGE_BUTTON); return true; } - if (onScrollbarBottom((int)mouseX, (int) mouseY) && nextPageVisible) { + if (onScrollbarBottom((int) mouseX, (int) mouseY) && nextPageVisible) { clickSlot(NEXT_PAGE_BUTTON); return true; } - if (onSearchField((int)mouseX, (int) mouseY)) { + if (onSearchField((int) mouseX, (int) mouseY)) { clickSlot(SEARCH_BUTTON_SLOT); return true; } @@ -205,6 +205,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 154 && localX < 169 && localY > 43 && localY < 80; } + private boolean onSearchField(int mouseX, int mouseY) { int localX = mouseX - x; int localY = mouseY - y; @@ -231,16 +232,19 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); - case AUCTION_TYPE_BUTTON_SLOT -> auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case SORT_BUTTON_SLOT -> + sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case AUCTION_TYPE_BUTTON_SLOT -> + auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); case RARITY_BUTTON_SLOT -> { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); int ordinal = getOrdinal(tooltip); - String split = tooltip.get(ordinal+2).getString().substring(2); - rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); + String split = tooltip.get(ordinal + 2).getString().substring(2); + rarityWidget.setText(tooltip.subList(1, tooltip.size() - 3), split); } case RESET_BUTTON_SLOT -> { - if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); + if (resetFiltersButton != null) + resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); } case SEARCH_BUTTON_SLOT -> { List tooltipSearch = stack.getTooltip(client.player, TooltipContext.BASIC); @@ -256,7 +260,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { - if (slotId < this.handler.getRows()*9 && slotId%9 == 0) { + if (slotId < this.handler.getRows() * 9 && slotId % 9 == 0) { CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); categoryTabWidget.setSlotId(slotId); categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); @@ -271,7 +275,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 9 && slotId < (handler.getRows()-1)*9 && slotId%9 > 1 && slotId%9 < 8) { + } else if (slotId > 9 && slotId < (handler.getRows() - 1) * 9 && slotId % 9 > 1 && slotId % 9 < 8) { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); if (!SkyblockerConfigManager.get().general.fancyAuctionHouse.highlightCheapBIN) return; for (int k = tooltip.size() - 1; k >= 0; k--) { @@ -295,7 +299,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI parsed); } - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } } } } @@ -305,9 +310,9 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip) { int ordinal = 0; - for (int j = 0; j < tooltip.size()-3; j++) { - if (j+2 >= tooltip.size()) break; - if (tooltip.get(j+2).getString().contains("▶")) { + for (int j = 0; j < tooltip.size() - 3; j++) { + if (j + 2 >= tooltip.size()) break; + if (tooltip.get(j + 2).getString().contains("▶")) { ordinal = j; break; } @@ -319,6 +324,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); @@ -328,12 +334,13 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI= (double)(left + this.backgroundWidth) || mouseY >= (double)(top + this.backgroundHeight); + return mouseX < (double) left - 32 || mouseY < (double) top || mouseX >= (double) (left + this.backgroundWidth) || mouseY >= (double) (top + this.backgroundHeight); } private static class ScaledTextButtonWidget extends ButtonWidget { @@ -350,7 +357,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { + buyButton = ButtonWidget.builder(isBinAuction ? Text.translatable("skyblocker.fancyAuctionHouse.buy") : Text.translatable("skyblocker.fancyAuctionHouse.bid"), button -> { if (buySlotID == -1) return; clickSlot(buySlotID); }).size(60, 15).build(); @@ -78,8 +78,8 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) - .position(x + backgroundWidth - 16, y+4) + addDrawableChild(new ButtonWidget.Builder(Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + backgroundWidth - 16, y + 4) .size(12, 12) .build()); @@ -94,10 +94,11 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.alreadyTopBid").withColor(Colors.LIGHT_YELLOW)); + case TOP_BID -> + infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.alreadyTopBid").withColor(Colors.LIGHT_YELLOW)); case AFFORD -> infoTextWidget.setMessage(Text.empty()); case COLLECT_AUCTION -> { - infoTextWidget.setMessage(changeProfile ? Text.translatable("skyblocker.fancyAuctionHouse.differentProfile"): wonAuction ? Text.empty() : Text.translatable("skyblocker.fancyAuctionHouse.didntWin")); + infoTextWidget.setMessage(changeProfile ? Text.translatable("skyblocker.fancyAuctionHouse.differentProfile") : wonAuction ? Text.empty() : Text.translatable("skyblocker.fancyAuctionHouse.didntWin")); //priceWidget.setMessage(Text.empty()); priceWidget.active = false; @@ -259,9 +260,9 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { // The regex removes [, ] and +. To ignore mvp++ rank and orange + in mvp+ - String res = Objects.equals(style.getColor(), TextColor.fromFormatting(Formatting.GOLD)) && !asString.matches(".*[]\\[+].*") && !asString.contains("Collect") ? asString: null; + String res = Objects.equals(style.getColor(), TextColor.fromFormatting(Formatting.GOLD)) && !asString.matches(".*[]\\[+].*") && !asString.contains("Collect") ? asString : null; return Optional.ofNullable(res); - }, Style.EMPTY).ifPresent(s -> stringAtomicReference.set(stringAtomicReference.get()+s)); + }, Style.EMPTY).ifPresent(s -> stringAtomicReference.set(stringAtomicReference.get() + s)); } //System.out.println("Experiment: " + stringAtomicReference.get()); if (priceString == null) priceString = stringAtomicReference.get(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java index 6853d0c4..86d5c44b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java @@ -34,7 +34,7 @@ public class EditBidPopup extends BarebonesPopupScreen { super.init(); layout = DirectionalLayoutWidget.vertical(); layout.spacing(8).getMainPositioner().alignHorizontalCenter(); - textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()){ + textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()) { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (!super.keyPressed(keyCode, scanCode, modifiers)) { -- cgit