From 24a77b37e8035e2b5e7c6d0f76adf13810ec2a26 Mon Sep 17 00:00:00 2001 From: StyStatic <97907654+stystatic@users.noreply.github.com> Date: Fri, 15 Sep 2023 17:16:12 -0700 Subject: [PATCH 1/9] Exotic Armor Identifier --- .../skyblock/item/PriceInfoTooltip.java | 43 ++ .../skyblocker/config/SkyblockerConfig.java | 650 ++++++++++++++++++ .../skyblock/item/exotic/CheckExotic.java | 105 +++ .../xmrvizzy/skyblocker/utils/Constants.java | 34 + .../assets/skyblocker/lang/en_us.json | 8 + 5 files changed, 840 insertions(+) create mode 100644 src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java create mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java index 0885ae6bb8..667382ee5d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.exotic.CheckExotic; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.ItemUtils; @@ -13,6 +14,7 @@ import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -35,6 +37,7 @@ public class PriceInfoTooltip { private static JsonObject lowestPricesJson; private static JsonObject isMuseumJson; private static JsonObject motesPricesJson; + public static JsonObject ColorApiData; private static volatile boolean nullMsgSend = false; private final static Gson gson = new Gson(); private static final Map apiAddresses; @@ -55,6 +58,45 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List neuName = internalID; } + if (lines.size() == 0) { + return; + } + + if (SkyblockerConfig.get().general.itemTooltip.enableExoticCheck) { + + if (ColorApiData == null) { // Only download once, don't need to waste resources on downloading every few seconds + ColorApiData = downloadPrices("color"); + } + + final NbtElement Color = stack.getNbt().getCompound("display").get("color"); + + if (Color != null) { + String colorHex = String.format("%06X", Integer.parseInt(Color.asString())); + String expectedHex = CheckExotic.getExpectedHex(internalID); + + boolean correctLine = false; + for (int i = 0; i < lines.size(); i++) { + String existingTooltip = String.valueOf(lines.get(i)); + if (existingTooltip.startsWith("Color: ")) { + correctLine = true; + + if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.checkExceptions(internalID, colorHex) && !CheckExotic.intendedDyed(stack.getNbt())) { + final String type = CheckExotic.checkDyeType(colorHex); + lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + " (" + CheckExotic.FormattingColor(type) + CheckExotic.getTranslatatedText(type).getString() + Formatting.DARK_GRAY + ")")); + } + break; + } + } + + if (!correctLine) { + if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.checkExceptions(internalID, colorHex) && !CheckExotic.intendedDyed(stack.getNbt())) { + final String type = CheckExotic.checkDyeType(colorHex); + lines.add(1, Text.literal(Formatting.DARK_GRAY + "(" + CheckExotic.FormattingColor(type) + CheckExotic.getTranslatatedText(type).getString() + Formatting.DARK_GRAY + ")")); + } + } + } + } + int count = stack.getCount(); boolean bazaarOpened = lines.stream().anyMatch(each -> each.getString().contains("Buy price:") || each.getString().contains("Sell price:")); @@ -421,5 +463,6 @@ public static JsonObject getLBINPrices() { apiAddresses.put("npc", "https://hysky.de/api/npcprice"); apiAddresses.put("museum", "https://hysky.de/api/museum"); apiAddresses.put("motes", "https://hysky.de/api/motesprice"); + apiAddresses.put("color", "https://hysky.de/api/color"); } } \ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java new file mode 100644 index 0000000000..7fc042e5d6 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -0,0 +1,650 @@ +package me.xmrvizzy.skyblocker.config; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; +import me.shedaniel.autoconfig.serializer.ConfigSerializer; +import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; +import me.xmrvizzy.skyblocker.SkyblockerMod; +import me.xmrvizzy.skyblocker.skyblock.item.CustomArmorTrims; +import me.xmrvizzy.skyblocker.utils.chat.ChatFilterResult; +import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +import java.util.ArrayList; +import java.util.List; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + +@Config(name = "skyblocker") +public class SkyblockerConfig implements ConfigData { + + @ConfigEntry.Category("general") + @ConfigEntry.Gui.TransitiveObject + public General general = new General(); + + @ConfigEntry.Category("locations") + @ConfigEntry.Gui.TransitiveObject + public Locations locations = new Locations(); + + @ConfigEntry.Category("slayer") + @ConfigEntry.Gui.TransitiveObject + public Slayer slayer = new Slayer(); + + @ConfigEntry.Category("quickNav") + @ConfigEntry.Gui.TransitiveObject + public QuickNav quickNav = new QuickNav(); + + @ConfigEntry.Category("messages") + @ConfigEntry.Gui.TransitiveObject + public Messages messages = new Messages(); + + @ConfigEntry.Category("richPresence") + @ConfigEntry.Gui.TransitiveObject + public RichPresence richPresence = new RichPresence(); + + public static class QuickNav { + public boolean enableQuickNav = true; + + @ConfigEntry.Category("button1") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button1 = new QuickNavItem(true, new ItemData("diamond_sword"), "Your Skills", "/skills"); + + @ConfigEntry.Category("button2") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button2 = new QuickNavItem(true, new ItemData("painting"), "Collections", "/collection"); + + @ConfigEntry.Category("button3") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button3 = new QuickNavItem(true, new ItemData("bone"), "\\Pets \\(\\d+/\\d+\\)", "/pets"); + + @ConfigEntry.Category("button4") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button4 = new QuickNavItem(true, new ItemData("leather_chestplate", 1, "tag:{display:{color:8991416}}"), "Wardrobe \\([12]/2\\)", "/wardrobe"); + + @ConfigEntry.Category("button5") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button5 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-2081424676,-57521078,-2073572414,158072763],Properties:{textures:[{Value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0=\"}]}}}"), "Sack of Sacks", "/sacks"); + + @ConfigEntry.Category("button6") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button6 = new QuickNavItem(true, new ItemData("ender_chest"), "(?:Rift )?Storage(?: \\(1/2\\))?", "/storage"); + + @ConfigEntry.Category("button7") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button7 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-300151517,-631415889,-1193921967,-1821784279],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}}}"), "none", "/hub"); + + @ConfigEntry.Category("button8") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;1605800870,415127827,-1236127084,15358548],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0=\"}]}}}"), "none", "/warp dungeon_hub"); + + @ConfigEntry.Category("button9") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-562285948,532499670,-1705302742,775653035],Properties:{textures:[{Value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjVkZjU1NTkyNjQzMGQ1ZDc1YWRlZDIxZGQ5NjE5Yjc2YzViN2NhMmM3ZjU0MDE0NDA1MjNkNTNhOGJjZmFhYiJ9fX0=\"}]}}}"), "Visit prtl", "/visit prtl"); + + @ConfigEntry.Category("button10") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button10 = new QuickNavItem(true, new ItemData("enchanting_table"), "Enchant Item", "/etable"); + + @ConfigEntry.Category("button11") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button11 = new QuickNavItem(true, new ItemData("anvil"), "Anvil", "/anvil"); + + @ConfigEntry.Category("button12") + @ConfigEntry.Gui.CollapsibleObject() + public QuickNavItem button12 = new QuickNavItem(true, new ItemData("crafting_table"), "Craft Item", "/craft"); + } + + public static class QuickNavItem { + public QuickNavItem(Boolean render, ItemData itemData, String uiTitle, String clickEvent) { + this.render = render; + this.item = itemData; + this.clickEvent = clickEvent; + this.uiTitle = uiTitle; + } + + public Boolean render; + + @ConfigEntry.Category("item") + @ConfigEntry.Gui.CollapsibleObject() + public ItemData item; + + public String uiTitle; + public String clickEvent; + } + + public static class ItemData { + public ItemData(String itemName, int count, String nbt) { + this.itemName = itemName; + this.count = count; + this.nbt = nbt; + } + + public ItemData(String itemName) { + this.itemName = itemName; + this.count = 1; + this.nbt = ""; + } + + public String itemName; + public int count; + public String nbt; + } + + public static class General { + public boolean acceptReparty = true; + public boolean backpackPreviewWithoutShift = false; + public boolean hideEmptyTooltips = true; + public boolean hideStatusEffectOverlay = false; + + @ConfigEntry.Category("tabHud") + @ConfigEntry.Gui.CollapsibleObject() + public TabHudConf tabHud = new TabHudConf(); + + @ConfigEntry.Gui.Excluded + public String apiKey; + + @ConfigEntry.Category("bars") + @ConfigEntry.Gui.CollapsibleObject() + public Bars bars = new Bars(); + + @ConfigEntry.Category("experiments") + @ConfigEntry.Gui.CollapsibleObject() + public Experiments experiments = new Experiments(); + + @ConfigEntry.Category("fishing") + @ConfigEntry.Gui.CollapsibleObject() + public Fishing fishing = new Fishing(); + + @ConfigEntry.Category("fairySouls") + @ConfigEntry.Gui.CollapsibleObject() + public FairySouls fairySouls = new FairySouls(); + + @ConfigEntry.Category("shortcuts") + @ConfigEntry.Gui.CollapsibleObject() + public Shortcuts shortcuts = new Shortcuts(); + + @ConfigEntry.Category("quiverWarning") + @ConfigEntry.Gui.CollapsibleObject() + public QuiverWarning quiverWarning = new QuiverWarning(); + + @ConfigEntry.Category("itemList") + @ConfigEntry.Gui.CollapsibleObject() + public ItemList itemList = new ItemList(); + + @ConfigEntry.Category("itemTooltip") + @ConfigEntry.Gui.CollapsibleObject() + public ItemTooltip itemTooltip = new ItemTooltip(); + + @ConfigEntry.Category("itemInfoDisplay") + @ConfigEntry.Gui.CollapsibleObject + public ItemInfoDisplay itemInfoDisplay = new ItemInfoDisplay(); + + @ConfigEntry.Category("specialEffects") + @ConfigEntry.Gui.CollapsibleObject + public SpecialEffects specialEffects = new SpecialEffects(); + + @ConfigEntry.Category("hitbox") + @ConfigEntry.Gui.CollapsibleObject() + public Hitbox hitbox = new Hitbox(); + + @ConfigEntry.Gui.Tooltip() + @ConfigEntry.Category("titleContainer") + @ConfigEntry.Gui.CollapsibleObject() + public TitleContainer titleContainer = new TitleContainer(); + + @ConfigEntry.Category("Teleport Overlay") + @ConfigEntry.Gui.CollapsibleObject() + public TeleportOverlay teleportOverlay = new TeleportOverlay(); + + @ConfigEntry.Gui.Excluded + public List lockedSlots = new ArrayList<>(); + + @ConfigEntry.Gui.Excluded + public Object2ObjectOpenHashMap customItemNames = new Object2ObjectOpenHashMap<>(); + + @ConfigEntry.Gui.Excluded + public Object2IntOpenHashMap customDyeColors = new Object2IntOpenHashMap<>(); + + @ConfigEntry.Gui.Excluded + public Object2ObjectOpenHashMap customArmorTrims = new Object2ObjectOpenHashMap<>(); + } + + public static class TabHudConf { + public boolean tabHudEnabled = true; + + @ConfigEntry.BoundedDiscrete(min = 10, max = 200) + @ConfigEntry.Gui.Tooltip() + public int tabHudScale = 100; + @ConfigEntry.Gui.Tooltip + public boolean plainPlayerNames = false; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + @ConfigEntry.Gui.Tooltip + public NameSorting nameSorting = NameSorting.DEFAULT; + } + + public enum NameSorting { + DEFAULT, + ALPHABETICAL; + + @Override + public String toString() { + return switch (this) { + case DEFAULT -> "Default"; + case ALPHABETICAL -> "Alphabetical"; + }; + } + } + + public static class Bars { + public boolean enableBars = true; + + @ConfigEntry.Category("barpositions") + @ConfigEntry.Gui.CollapsibleObject() + public BarPositions barpositions = new BarPositions(); + } + + public static class BarPositions { + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public BarPosition healthBarPosition = BarPosition.LAYER1; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public BarPosition manaBarPosition = BarPosition.LAYER1; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public BarPosition defenceBarPosition = BarPosition.LAYER1; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public BarPosition experienceBarPosition = BarPosition.LAYER1; + + } + + public enum BarPosition { + LAYER1, + LAYER2, + RIGHT, + NONE; + + @Override + public String toString() { + return I18n.translate("text.autoconfig.skyblocker.option.general.bars.barpositions." + name()); + } + + public int toInt() { + return switch (this) { + case LAYER1 -> 0; + case LAYER2 -> 1; + case RIGHT -> 2; + case NONE -> -1; + }; + } + } + + public static class Experiments { + public boolean enableChronomatronSolver = true; + public boolean enableSuperpairsSolver = true; + public boolean enableUltrasequencerSolver = true; + } + + public static class Fishing { + public boolean enableFishingHelper = true; + } + + public static class FairySouls { + public boolean enableFairySoulsHelper = false; + } + + public static class Shortcuts { + @ConfigEntry.Gui.Tooltip() + public boolean enableShortcuts = true; + @ConfigEntry.Gui.Tooltip() + public boolean enableCommandShortcuts = true; + @ConfigEntry.Gui.Tooltip() + public boolean enableCommandArgShortcuts = true; + } + + public static class QuiverWarning { + public boolean enableQuiverWarning = true; + public boolean enableQuiverWarningInDungeons = true; + public boolean enableQuiverWarningAfterDungeon = true; + } + + public static class Hitbox { + public boolean oldFarmlandHitbox = true; + public boolean oldLeverHitbox = false; + } + + public static class TitleContainer { + @ConfigEntry.BoundedDiscrete(min = 30, max = 140) + public float titleContainerScale = 100; + public int x = 540; + public int y = 10; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public Direction direction = Direction.HORIZONTAL; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.DROPDOWN) + public Alignment alignment = Alignment.MIDDLE; + } + + public static class TeleportOverlay { + public boolean enableTeleportOverlays = true; + public boolean enableWeirdTransmission = true; + public boolean enableInstantTransmission = true; + public boolean enableEtherTransmission = true; + public boolean enableSinrecallTransmission = true; + public boolean enableWitherImpact = true; + } + + public enum Direction { + HORIZONTAL, + VERTICAL; + + @Override + public String toString() { + return switch (this) { + case HORIZONTAL -> "Horizontal"; + case VERTICAL -> "Vertical"; + }; + } + } + + public enum Alignment { + LEFT, + RIGHT, + MIDDLE; + + @Override + public String toString() { + return switch (this) { + case LEFT -> "Left"; + case RIGHT -> "Right"; + case MIDDLE -> "Middle"; + }; + } + } + + public static class RichPresence { + public boolean enableRichPresence = false; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + @ConfigEntry.Gui.Tooltip() + public Info info = Info.LOCATION; + public boolean cycleMode = false; + public String customMessage = "Playing Skyblock"; + } + + public static class ItemList { + public boolean enableItemList = true; + } + + public enum Average { + ONE_DAY, + THREE_DAY, + BOTH; + + @Override + public String toString() { + return I18n.translate("text.autoconfig.skyblocker.option.general.itemTooltip.avg." + name()); + } + } + + public static class ItemTooltip { + public boolean enableExoticCheck = true; + public boolean enableNPCPrice = true; + @ConfigEntry.Gui.Tooltip + public boolean enableMotesPrice = true; + public boolean enableAvgBIN = true; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + @ConfigEntry.Gui.Tooltip() + public Average avg = Average.THREE_DAY; + public boolean enableLowestBIN = true; + public boolean enableBazaarPrice = true; + public boolean enableMuseumDate = true; + } + + public static class ItemInfoDisplay { + @ConfigEntry.Gui.Tooltip + public boolean attributeShardInfo = true; + } + + public static class SpecialEffects { + @ConfigEntry.Gui.Tooltip + public boolean rareDungeonDropEffects = true; + } + + public static class Locations { + @ConfigEntry.Category("barn") + @ConfigEntry.Gui.CollapsibleObject() + public Barn barn = new Barn(); + + @ConfigEntry.Category("dungeons") + @ConfigEntry.Gui.CollapsibleObject() + public Dungeons dungeons = new Dungeons(); + + @ConfigEntry.Category("dwarvenmines") + @ConfigEntry.Gui.CollapsibleObject() + public DwarvenMines dwarvenMines = new DwarvenMines(); + + @ConfigEntry.Category("rift") + @ConfigEntry.Gui.CollapsibleObject() + public Rift rift = new Rift(); + } + + public static class Dungeons { + @ConfigEntry.Gui.CollapsibleObject + public SecretWaypoints secretWaypoints = new SecretWaypoints(); + @ConfigEntry.Gui.CollapsibleObject + public DungeonChestProfit dungeonChestProfit = new DungeonChestProfit(); + @ConfigEntry.Gui.Tooltip() + public boolean croesusHelper = true; + public boolean enableMap = true; + public float mapScaling = 1f; + public int mapX = 2; + public int mapY = 2; + @ConfigEntry.Gui.Tooltip + public boolean starredMobGlow = true; + public boolean solveThreeWeirdos = true; + @ConfigEntry.Gui.Tooltip + public boolean blazesolver = true; + public boolean solveTrivia = true; + @ConfigEntry.Gui.Tooltip + public boolean solveTicTacToe = true; + @ConfigEntry.Gui.CollapsibleObject + public LividColor lividColor = new LividColor(); + @ConfigEntry.Gui.CollapsibleObject() + public Terminals terminals = new Terminals(); + } + + public static class SecretWaypoints { + + public boolean enableSecretWaypoints = true; + @ConfigEntry.Gui.Tooltip() + public boolean noInitSecretWaypoints = false; + public boolean enableEntranceWaypoints = true; + public boolean enableSuperboomWaypoints = true; + public boolean enableChestWaypoints = true; + public boolean enableItemWaypoints = true; + public boolean enableBatWaypoints = true; + public boolean enableWitherWaypoints = true; + public boolean enableLeverWaypoints = true; + public boolean enableFairySoulWaypoints = true; + public boolean enableStonkWaypoints = true; + @ConfigEntry.Gui.Tooltip() + public boolean enableDefaultWaypoints = true; + } + + public static class DungeonChestProfit { + @ConfigEntry.Gui.Tooltip + public boolean enableProfitCalculator = true; + @ConfigEntry.Gui.Tooltip + public boolean includeKismet = false; + @ConfigEntry.Gui.Tooltip + public boolean includeEssence = true; + } + + public static class LividColor { + @ConfigEntry.Gui.Tooltip() + public boolean enableLividColor = true; + @ConfigEntry.Gui.Tooltip() + public String lividColorText = "The livid color is [color]"; + } + + public static class Terminals { + public boolean solveColor = true; + public boolean solveOrder = true; + public boolean solveStartsWith = true; + } + + public static class DwarvenMines { + public boolean enableDrillFuel = true; + public boolean solveFetchur = true; + public boolean solvePuzzler = true; + @ConfigEntry.Gui.CollapsibleObject() + public DwarvenHud dwarvenHud = new DwarvenHud(); + } + + public static class DwarvenHud { + public boolean enabled = true; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + @ConfigEntry.Gui.Tooltip(count = 3) + public DwarvenHudStyle style = DwarvenHudStyle.SIMPLE; + public boolean enableBackground = true; + public int x = 10; + public int y = 10; + } + + public enum DwarvenHudStyle { + SIMPLE, + FANCY, + CLASSIC; + + @Override + public String toString() { + return switch (this) { + case SIMPLE -> "Simple"; + case FANCY -> "Fancy"; + case CLASSIC -> "Classic"; + }; + } + } + + public static class Barn { + public boolean solveHungryHiker = true; + public boolean solveTreasureHunter = true; + } + + public static class Rift { + public boolean mirrorverseWaypoints = true; + @ConfigEntry.BoundedDiscrete(min = 0, max = 5) + @ConfigEntry.Gui.Tooltip + public int mcGrubberStacks = 0; + } + + public static class Slayer { + @ConfigEntry.Category("vampire") + @ConfigEntry.Gui.CollapsibleObject() + public VampireSlayer vampireSlayer = new VampireSlayer(); + } + + public static class VampireSlayer { + public boolean enableEffigyWaypoints = true; + public boolean compactEffigyWaypoints; + @ConfigEntry.BoundedDiscrete(min = 1, max = 10) + @ConfigEntry.Gui.Tooltip() + public int effigyUpdateFrequency = 5; + public boolean enableHolyIceIndicator = true; + public int holyIceIndicatorTickDelay = 10; + @ConfigEntry.BoundedDiscrete(min = 1, max = 10) + @ConfigEntry.Gui.Tooltip() + public int holyIceUpdateFrequency = 5; + public boolean enableHealingMelonIndicator = true; + public float healingMelonHealthThreshold = 4F; + public boolean enableSteakStakeIndicator = true; + @ConfigEntry.BoundedDiscrete(min = 1, max = 10) + @ConfigEntry.Gui.Tooltip() + public int steakStakeUpdateFrequency = 5; + public boolean enableManiaIndicator = true; + @ConfigEntry.BoundedDiscrete(min = 1, max = 10) + @ConfigEntry.Gui.Tooltip() + public int maniaUpdateFrequency = 5; + } + + public static class Messages { + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideAbility = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideHeal = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideAOTE = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideImplosion = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideMoltenWave = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideAds = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideTeleportPad = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideCombo = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + public ChatFilterResult hideAutopet = ChatFilterResult.PASS; + @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) + @ConfigEntry.Gui.Tooltip + public ChatFilterResult hideShowOff = ChatFilterResult.PASS; + @ConfigEntry.Gui.Tooltip() + public boolean hideMana = false; + } + + public enum Info { + PURSE, + BITS, + LOCATION; + + @Override + public String toString() { + return I18n.translate("text.autoconfig.skyblocker.option.richPresence.info." + name()); + } + } + + /** + * Registers the config to AutoConfig and registers commands to open the config screen. + */ + public static void init() { + Gson gson = new GsonBuilder() + .setPrettyPrinting() + .registerTypeHierarchyAdapter(Text.class, new Text.Serializer()) + .registerTypeHierarchyAdapter(Style.class, new Style.Serializer()) + .registerTypeHierarchyAdapter(Identifier.class, new Identifier.Serializer()) + .create(); + + ConfigSerializer.Factory serializer = (cfg, cfgClass) -> new GsonConfigSerializer<>(cfg, cfgClass, gson); + + AutoConfig.register(SkyblockerConfig.class, serializer); + ClientCommandRegistrationCallback.EVENT.register(((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(optionsLiteral("config")).then(optionsLiteral("options"))))); + } + + /** + * Registers an options command with the given name. Used for registering both options and config as valid commands. + * + * @param name the name of the command node + * @return the command builder + */ + private static LiteralArgumentBuilder optionsLiteral(String name) { + // Don't immediately open the next screen as it will be closed by ChatScreen right after this command is executed + return literal(name).executes(Scheduler.queueOpenScreenCommand(AutoConfig.getConfigScreen(SkyblockerConfig.class, null))); + } + + public static SkyblockerConfig get() { + return AutoConfig.getConfigHolder(SkyblockerConfig.class).getConfig(); + } + + public static void save() { + AutoConfig.getConfigHolder(SkyblockerConfig.class).save(); + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java new file mode 100644 index 0000000000..fb22362e5c --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java @@ -0,0 +1,105 @@ +package me.xmrvizzy.skyblocker.skyblock.item.exotic; + +import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip; +import me.xmrvizzy.skyblocker.utils.Constants; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +public class CheckExotic { + static String[] SeymourIDS = {"VELVET_TOP_HAT", "CASHMERE_JACKET", "SATIN_TROUSERS", "OXFORD_SHOES"}; + public static String getExpectedHex(String id) { + String color = PriceInfoTooltip.ColorApiData.get(id).getAsString(); + if (color != null) { + String[] RGBValues = color.split(","); + String hex = String.format("%02x%02x%02x", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2])); + return hex.toUpperCase(); + } else { + System.out.println("Color is null"); + return null; + } + } + + public static Boolean checkExceptions(String id, String hex) { + if (id.startsWith("LEATHER") || id.equals("GHOST_BOOTS") || ListContainsString(SeymourIDS, id)) { + return true; + } + if (id.startsWith("RANCHER")) { + return ListContainsString(Constants.Ranchers, hex); + } + if (id.contains("ADAPTIVE_CHESTPLATE")) { + return ListContainsString(Constants.AdaptiveChest, hex); + } else if (id.contains("ADAPTIVE")) { + return ListContainsString(Constants.Adaptive, hex); + } + if (id.startsWith("REAPER")) { + return ListContainsString(Constants.Reaper, hex); + } + if (id.startsWith("FAIRY")) { + return ListContainsString(Constants.FairyHexes, hex); + } + if (id.startsWith("CRYSTAL")) { + return ListContainsString(Constants.CrystalHexes, hex); + } + if (id.contains("SPOOK")) { + return ListContainsString(Constants.Spook, hex); + } + return false; + } + + public static String checkDyeType(String ActualHex) { + if (ListContainsString(Constants.CrystalHexes, ActualHex)) { + return "CRYSTAL"; + } + if (ListContainsString(Constants.FairyHexes, ActualHex)) { + return "FAIRY"; + } + if (ListContainsString(Constants.OgFairyHexes, ActualHex)) { + return "OG_FAIRY"; + } + if (ListContainsString(Constants.Spook, ActualHex)) { + return "SPOOK"; + } + if (ListContainsString(Constants.Glitched, ActualHex)) { + return "GLITCHED"; + } + return "EXOTIC"; + } + + private static Boolean ListContainsString(String[] list, String s) { + for (int i = 0; i < list.length; i++) { + if (list[i].equalsIgnoreCase(s)) { + return true; + } + } + return false; + } + + public static Boolean intendedDyed(NbtCompound ItemData) { + return ItemData.getCompound("ExtraAttributes").getKeys().contains("dye_item"); + } + + public static Formatting FormattingColor(String s) { + switch (s) { + case "CRYSTAL": return Formatting.AQUA; + case "FAIRY": return Formatting.LIGHT_PURPLE; + case "OG_FAIRY": return Formatting.DARK_PURPLE; + case "SPOOK": return Formatting.RED; + case "GLITCHED": return Formatting.BLUE; + case "EXOTIC": return Formatting.GOLD; + } + return Formatting.DARK_GRAY; + } + + public static Text getTranslatatedText(String s) { + switch (s) { + case "CRYSTAL": return Text.translatable("skyblocker.exotic.crystal"); + case "FAIRY": return Text.translatable("skyblocker.exotic.fairy"); + case "OG_FAIRY": return Text.translatable("skyblocker.exotic.og_fairy"); + case "SPOOK": return Text.translatable("skyblocker.exotic.spook"); + case "GLITCHED": return Text.translatable("skyblocker.exotic.glitched"); + case "EXOTIC": return Text.translatable("skyblocker.exotic.exotic"); + } + return null; + } +} diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java new file mode 100644 index 0000000000..23d4a43f5d --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java @@ -0,0 +1,34 @@ +package me.xmrvizzy.skyblocker.utils; + +/** + * Holds generic static constants + */ +public interface Constants { + String LEVEL_EMBLEMS = "\u2E15\u273F\u2741\u2E19\u03B1\u270E\u2615\u2616\u2663\u213B\u2694\u27B6\u26A1\u2604\u269A\u2693\u2620\u269B\u2666\u2660\u2764\u2727\u238A\u1360\u262C\u269D\u29C9\uA214\u32D6\u2E0E\u26A0\uA541\u3020\u30C4\u2948\u2622\u2623\u273E\u269C\u0BD0\u0A6D\u2742\u16C3\u3023\u10F6\u0444\u266A\u266B\u04C3\u26C1\u26C3\u16DD\uA03E\u1C6A\u03A3\u09EB\u2603\u2654\u26C2\u12DE"; + + // Exotic Hexes + String[] CrystalHexes = {"1F0030", "46085E", "54146E", "5D1C78", "63237D", "6A2C82", "7E4196", "8E51A6", "9C64B3", "A875BD", + "B88BC9", "C6A3D4", "D9C1E3", "E5D1ED", "EFE1F5", "FCF3FF"}; + String[] FairyHexes = {"330066", "4C0099", "660033", "660066", "6600CC", "7F00FF", "99004C", "990099", "9933FF", "B266FF", + "CC0066", "CC00CC", "CC99FF", "E5CCFF", "FF007F", "FF00FF", "FF3399", "FF33FF", "FF66B2", "FF66FF", "FF99CC", "FF99FF", "FFCCE5", + "FFCCFF"}; + + String[] OgFairyHexes = {"FF99FF", "FFCCFF", "E5CCFF", "CC99FF", "CC00CC", "FF00FF", "FF33FF", "FF66FF", + "B266FF", "9933FF", "7F00FF", "660066", "6600CC", "4C0099", "330066", "990099", "660033", "99004C", "CC0066", + "660033", "99004C", "FFCCE5", "660033", "FFCCE5", "FF99CC", "FFCCE5", "FF99CC", "FF66B2"}; + + String[] Glitched = {"FFDC51", "F7DA33", "606060", "E7413C", "45413C", "4A14B7", "1793C4", "000000", "E75C3C", "65605A", + "5D2FB9", "17A8C4", "E76E3C", "88837E", "8969C8", "1CD4E4"}; // Glitched through other means such as Shark Scale upgrade color + + String[] Spook = {"000000", "070008", "0E000F", "150017", "1B001F", "220027", "29002E", "300036", "37003E", "3E0046", + "45004D", "4C0055", "52005D", "590065", "60006C", "670074", "6E007C", "750084", "7C008B", "830093", + "89009B", "9000A3", "9700AA", "993399", "9E00B2"}; + + // List of exceptions + + String[] Ranchers = {"CC5500", "000000", "0"}; + String[] Reaper = {"1B1B1B", "FF0000"}; + + String[] AdaptiveChest = {"3ABE78", "82E3D8", "BFBCB2", "D579FF", "FF4242", "FFC234"}; + String[] Adaptive = {"169F57", "2AB5A5", "6E00A0", "BB0000", "BFBCB2", "FFF7E6"}; +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 8665ce459a..990fc35177 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -65,6 +65,7 @@ "text.autoconfig.skyblocker.option.general.tabHud.nameSorting": "Player Name Sorting Method", "text.autoconfig.skyblocker.option.general.tabHud.nameSorting.@Tooltip": "Alphabetical sorting sorts names alphabetically while Default has no particular order.", "text.autoconfig.skyblocker.option.general.itemTooltip": "Item Tooltip", + "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck": "Enable Exotic Check", "text.autoconfig.skyblocker.option.general.itemTooltip.enableNPCPrice": "Enable NPC Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice": "Enable Motes Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice.@Tooltip": "Displays the Motes sell price of an item while in The Rift.", @@ -279,6 +280,13 @@ "skyblocker.dungeons.secrets.customWaypointRemoved": "§rRemoved custom waypoint at X: %d, Y: %d, Z: %d for room %s secret #%d of category %s with name '%s'.", "skyblocker.dungeons.secrets.customWaypointNotFound": "§cNo custom waypoint found at X: %d, Y: %d, Z: %d for room %s.", + "skyblocker.exotic.crystal": "CRYSTAL", + "skyblocker.exotic.fairy": "FAIRY", + "skyblocker.exotic.og_fairy": "OG_FAIRY", + "skyblocker.exotic.spook": "SPOOK", + "skyblocker.exotic.glitched": "GLITCHED", + "skyblocker.exotic.exotic": "EXOTIC", + "skyblocker.fishing.reelNow": "Reel in now!", "skyblocker.rift.healNow": "Heal now!", "skyblocker.rift.iceNow": "Ice now!", From ceb5dbbea4079eadca90a96e714cc5539700a5d4 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 15 Sep 2023 23:46:12 -0400 Subject: [PATCH 2/9] Refactor CheckExotic --- .../skyblock/item/PriceInfoTooltip.java | 61 +++++++------- .../java/de/hysky/skyblocker/utils/Utils.java | 2 +- .../skyblock/item/exotic/CheckExotic.java | 79 ++++++++----------- .../xmrvizzy/skyblocker/utils/Constants.java | 53 ++++++------- 4 files changed, 90 insertions(+), 105 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java index 667382ee5d..3ecbe8bed2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.item; -import com.google.gson.Gson; import com.google.gson.JsonObject; +import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.item.exotic.CheckExotic; @@ -37,7 +37,7 @@ public class PriceInfoTooltip { private static JsonObject lowestPricesJson; private static JsonObject isMuseumJson; private static JsonObject motesPricesJson; - public static JsonObject ColorApiData; + public static JsonObject colorJson; private static volatile boolean nullMsgSend = false; private final static Gson gson = new Gson(); private static final Map apiAddresses; @@ -45,7 +45,7 @@ public class PriceInfoTooltip { private static long museumHash = 0; private static long motesHash = 0; - public static void onInjectTooltip(ItemStack stack, TooltipContext context, List lines) { + public static void getTooltip(ItemStack stack, TooltipContext context, List lines) { if (!Utils.isOnSkyblock() || client.player == null) return; String name = getInternalNameFromNBT(stack, false); @@ -58,40 +58,33 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List neuName = internalID; } - if (lines.size() == 0) { + if (lines.isEmpty()) { return; } if (SkyblockerConfig.get().general.itemTooltip.enableExoticCheck) { + if (colorJson == null) { + nullWarning(); + } else if (stack.getNbt() != null) { + final NbtElement color = stack.getNbt().getCompound("display").get("color"); - if (ColorApiData == null) { // Only download once, don't need to waste resources on downloading every few seconds - ColorApiData = downloadPrices("color"); - } - - final NbtElement Color = stack.getNbt().getCompound("display").get("color"); - - if (Color != null) { - String colorHex = String.format("%06X", Integer.parseInt(Color.asString())); - String expectedHex = CheckExotic.getExpectedHex(internalID); + if (color != null) { + String colorHex = String.format("%06X", Integer.parseInt(color.asString())); + String expectedHex = CheckExotic.getExpectedHex(internalID); - boolean correctLine = false; - for (int i = 0; i < lines.size(); i++) { - String existingTooltip = String.valueOf(lines.get(i)); - if (existingTooltip.startsWith("Color: ")) { - correctLine = true; + boolean correctLine = false; + for (Text text : lines) { + String existingTooltip = text.getString() + " "; + if (existingTooltip.startsWith("Color: ")) { + correctLine = true; - if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.checkExceptions(internalID, colorHex) && !CheckExotic.intendedDyed(stack.getNbt())) { - final String type = CheckExotic.checkDyeType(colorHex); - lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + " (" + CheckExotic.FormattingColor(type) + CheckExotic.getTranslatatedText(type).getString() + Formatting.DARK_GRAY + ")")); + addExoticTooltip(lines, internalID, stack.getNbt(), colorHex, expectedHex, existingTooltip); + break; } - break; } - } - if (!correctLine) { - if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.checkExceptions(internalID, colorHex) && !CheckExotic.intendedDyed(stack.getNbt())) { - final String type = CheckExotic.checkDyeType(colorHex); - lines.add(1, Text.literal(Formatting.DARK_GRAY + "(" + CheckExotic.FormattingColor(type) + CheckExotic.getTranslatatedText(type).getString() + Formatting.DARK_GRAY + ")")); + if (!correctLine) { + addExoticTooltip(lines, internalID, stack.getNbt(), colorHex, expectedHex, ""); } } } @@ -237,6 +230,13 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List } } + private static void addExoticTooltip(List lines, String internalID, NbtCompound nbt, String colorHex, String expectedHex, String existingTooltip) { + if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.isException(internalID, colorHex) && !CheckExotic.intendedDyed(nbt)) { + final String type = CheckExotic.checkDyeType(colorHex); + lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + "(").append(CheckExotic.getTranslatedText(type).formatted(CheckExotic.getFormattingColor(type))).append(Formatting.DARK_GRAY + ")")); + } + } + private static void nullWarning() { if (!nullMsgSend && client.player != null) { client.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemTooltip.nullMessage")), false); @@ -304,7 +304,7 @@ public static String getInternalNameFromNBT(ItemStack stack, boolean internalIDO } case "PET" -> { if (ea.contains("petInfo")) { - JsonObject petInfo = gson.fromJson(ea.getString("petInfo"), JsonObject.class); + JsonObject petInfo = SkyblockerMod.GSON.fromJson(ea.getString("petInfo"), JsonObject.class); return "LVL_1_" + petInfo.get("tier").getAsString() + "_" + petInfo.get("type").getAsString(); } } @@ -416,6 +416,9 @@ public static void init() { if (SkyblockerConfigManager.get().general.itemTooltip.enableMotesPrice && motesPricesJson == null) futureList.add(CompletableFuture.runAsync(() -> motesPricesJson = downloadPrices("motes"))); + if (SkyblockerConfig.get().general.itemTooltip.enableExoticCheck && colorJson == null) + futureList.add(CompletableFuture.runAsync(() -> colorJson = downloadPrices("color"))); + minute++; CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])) .whenComplete((unused, throwable) -> nullMsgSend = false); @@ -439,7 +442,7 @@ private static JsonObject downloadPrices(String type) { String apiResponse = Http.sendGetRequest(url); - return new Gson().fromJson(apiResponse, JsonObject.class); + return SkyblockerMod.GSON.fromJson(apiResponse, JsonObject.class); } catch (Exception e) { LOGGER.warn("[Skyblocker] Failed to download " + type + " prices!", e); return null; diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index ff406b61b3..0f87e8c448 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -180,7 +180,7 @@ public static void updatePlayerPresenceFromScoreboard(MinecraftClient client) { if (!isOnSkyblock) { if (!isInjected) { isInjected = true; - ItemTooltipCallback.EVENT.register(PriceInfoTooltip::onInjectTooltip); + ItemTooltipCallback.EVENT.register(PriceInfoTooltip::getTooltip); } isOnSkyblock = true; SkyblockEvents.JOIN.invoker().onSkyblockJoin(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java index fb22362e5c..c1b90f068e 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java @@ -3,13 +3,13 @@ import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip; import me.xmrvizzy.skyblocker.utils.Constants; import net.minecraft.nbt.NbtCompound; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; public class CheckExotic { - static String[] SeymourIDS = {"VELVET_TOP_HAT", "CASHMERE_JACKET", "SATIN_TROUSERS", "OXFORD_SHOES"}; public static String getExpectedHex(String id) { - String color = PriceInfoTooltip.ColorApiData.get(id).getAsString(); + String color = PriceInfoTooltip.colorJson.get(id).getAsString(); if (color != null) { String[] RGBValues = color.split(","); String hex = String.format("%02x%02x%02x", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2])); @@ -20,86 +20,69 @@ public static String getExpectedHex(String id) { } } - public static Boolean checkExceptions(String id, String hex) { - if (id.startsWith("LEATHER") || id.equals("GHOST_BOOTS") || ListContainsString(SeymourIDS, id)) { + public static boolean isException(String id, String hex) { + if (id.startsWith("LEATHER") || id.equals("GHOST_BOOTS") || Constants.SEYMOUR_IDS.contains(id)) { return true; } if (id.startsWith("RANCHER")) { - return ListContainsString(Constants.Ranchers, hex); + return Constants.RANCHERS.contains(hex); } if (id.contains("ADAPTIVE_CHESTPLATE")) { - return ListContainsString(Constants.AdaptiveChest, hex); + return Constants.ADAPTIVE_CHEST.contains(hex); } else if (id.contains("ADAPTIVE")) { - return ListContainsString(Constants.Adaptive, hex); + return Constants.ADAPTIVE.contains(hex); } if (id.startsWith("REAPER")) { - return ListContainsString(Constants.Reaper, hex); + return Constants.REAPER.contains(hex); } if (id.startsWith("FAIRY")) { - return ListContainsString(Constants.FairyHexes, hex); + return Constants.FAIRY_HEXES.contains(hex); } if (id.startsWith("CRYSTAL")) { - return ListContainsString(Constants.CrystalHexes, hex); + return Constants.CRYSTAL_HEXES.contains(hex); } if (id.contains("SPOOK")) { - return ListContainsString(Constants.Spook, hex); + return Constants.SPOOK.contains(hex); } return false; } - public static String checkDyeType(String ActualHex) { - if (ListContainsString(Constants.CrystalHexes, ActualHex)) { + public static String checkDyeType(String hex) { + if (Constants.CRYSTAL_HEXES.contains(hex)) { return "CRYSTAL"; } - if (ListContainsString(Constants.FairyHexes, ActualHex)) { + if (Constants.FAIRY_HEXES.contains(hex)) { return "FAIRY"; } - if (ListContainsString(Constants.OgFairyHexes, ActualHex)) { + if (Constants.OG_FAIRY_HEXES.contains(hex)) { return "OG_FAIRY"; } - if (ListContainsString(Constants.Spook, ActualHex)) { + if (Constants.SPOOK.contains(hex)) { return "SPOOK"; } - if (ListContainsString(Constants.Glitched, ActualHex)) { + if (Constants.GLITCHED.contains(hex)) { return "GLITCHED"; } return "EXOTIC"; } - private static Boolean ListContainsString(String[] list, String s) { - for (int i = 0; i < list.length; i++) { - if (list[i].equalsIgnoreCase(s)) { - return true; - } - } - return false; - } - - public static Boolean intendedDyed(NbtCompound ItemData) { - return ItemData.getCompound("ExtraAttributes").getKeys().contains("dye_item"); + public static boolean intendedDyed(NbtCompound ItemData) { + return ItemData.getCompound("ExtraAttributes").contains("dye_item"); } - public static Formatting FormattingColor(String s) { - switch (s) { - case "CRYSTAL": return Formatting.AQUA; - case "FAIRY": return Formatting.LIGHT_PURPLE; - case "OG_FAIRY": return Formatting.DARK_PURPLE; - case "SPOOK": return Formatting.RED; - case "GLITCHED": return Formatting.BLUE; - case "EXOTIC": return Formatting.GOLD; - } - return Formatting.DARK_GRAY; + public static Formatting getFormattingColor(String s) { + return switch (s) { + case "CRYSTAL" -> Formatting.AQUA; + case "FAIRY" -> Formatting.LIGHT_PURPLE; + case "OG_FAIRY" -> Formatting.DARK_PURPLE; + case "SPOOK" -> Formatting.RED; + case "GLITCHED" -> Formatting.BLUE; + case "EXOTIC" -> Formatting.GOLD; + default -> Formatting.DARK_GRAY; + }; } - public static Text getTranslatatedText(String s) { - switch (s) { - case "CRYSTAL": return Text.translatable("skyblocker.exotic.crystal"); - case "FAIRY": return Text.translatable("skyblocker.exotic.fairy"); - case "OG_FAIRY": return Text.translatable("skyblocker.exotic.og_fairy"); - case "SPOOK": return Text.translatable("skyblocker.exotic.spook"); - case "GLITCHED": return Text.translatable("skyblocker.exotic.glitched"); - case "EXOTIC": return Text.translatable("skyblocker.exotic.exotic"); - } - return null; + public static MutableText getTranslatedText(String s) { + return Text.translatable("skyblocker.exotic." + s.toLowerCase()); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java index 23d4a43f5d..a10e602550 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java @@ -1,34 +1,33 @@ package me.xmrvizzy.skyblocker.utils; +import java.util.List; + /** * Holds generic static constants */ public interface Constants { - String LEVEL_EMBLEMS = "\u2E15\u273F\u2741\u2E19\u03B1\u270E\u2615\u2616\u2663\u213B\u2694\u27B6\u26A1\u2604\u269A\u2693\u2620\u269B\u2666\u2660\u2764\u2727\u238A\u1360\u262C\u269D\u29C9\uA214\u32D6\u2E0E\u26A0\uA541\u3020\u30C4\u2948\u2622\u2623\u273E\u269C\u0BD0\u0A6D\u2742\u16C3\u3023\u10F6\u0444\u266A\u266B\u04C3\u26C1\u26C3\u16DD\uA03E\u1C6A\u03A3\u09EB\u2603\u2654\u26C2\u12DE"; - - // Exotic Hexes - String[] CrystalHexes = {"1F0030", "46085E", "54146E", "5D1C78", "63237D", "6A2C82", "7E4196", "8E51A6", "9C64B3", "A875BD", - "B88BC9", "C6A3D4", "D9C1E3", "E5D1ED", "EFE1F5", "FCF3FF"}; - String[] FairyHexes = {"330066", "4C0099", "660033", "660066", "6600CC", "7F00FF", "99004C", "990099", "9933FF", "B266FF", - "CC0066", "CC00CC", "CC99FF", "E5CCFF", "FF007F", "FF00FF", "FF3399", "FF33FF", "FF66B2", "FF66FF", "FF99CC", "FF99FF", "FFCCE5", - "FFCCFF"}; - - String[] OgFairyHexes = {"FF99FF", "FFCCFF", "E5CCFF", "CC99FF", "CC00CC", "FF00FF", "FF33FF", "FF66FF", - "B266FF", "9933FF", "7F00FF", "660066", "6600CC", "4C0099", "330066", "990099", "660033", "99004C", "CC0066", - "660033", "99004C", "FFCCE5", "660033", "FFCCE5", "FF99CC", "FFCCE5", "FF99CC", "FF66B2"}; - - String[] Glitched = {"FFDC51", "F7DA33", "606060", "E7413C", "45413C", "4A14B7", "1793C4", "000000", "E75C3C", "65605A", - "5D2FB9", "17A8C4", "E76E3C", "88837E", "8969C8", "1CD4E4"}; // Glitched through other means such as Shark Scale upgrade color - - String[] Spook = {"000000", "070008", "0E000F", "150017", "1B001F", "220027", "29002E", "300036", "37003E", "3E0046", - "45004D", "4C0055", "52005D", "590065", "60006C", "670074", "6E007C", "750084", "7C008B", "830093", - "89009B", "9000A3", "9700AA", "993399", "9E00B2"}; - - // List of exceptions - - String[] Ranchers = {"CC5500", "000000", "0"}; - String[] Reaper = {"1B1B1B", "FF0000"}; - - String[] AdaptiveChest = {"3ABE78", "82E3D8", "BFBCB2", "D579FF", "FF4242", "FFC234"}; - String[] Adaptive = {"169F57", "2AB5A5", "6E00A0", "BB0000", "BFBCB2", "FFF7E6"}; + String LEVEL_EMBLEMS = "\u2E15\u273F\u2741\u2E19\u03B1\u270E\u2615\u2616\u2663\u213B\u2694\u27B6\u26A1\u2604\u269A\u2693\u2620\u269B\u2666\u2660\u2764\u2727\u238A\u1360\u262C\u269D\u29C9\uA214\u32D6\u2E0E\u26A0\uA541\u3020\u30C4\u2948\u2622\u2623\u273E\u269C\u0BD0\u0A6D\u2742\u16C3\u3023\u10F6\u0444\u266A\u266B\u04C3\u26C1\u26C3\u16DD\uA03E\u1C6A\u03A3\u09EB\u2603\u2654\u26C2\u12DE"; + + List SEYMOUR_IDS = List.of("VELVET_TOP_HAT", "CASHMERE_JACKET", "SATIN_TROUSERS", "OXFORD_SHOES"); + + // Exotic Hexes + List CRYSTAL_HEXES = List.of("1F0030", "46085E", "54146E", "5D1C78", "63237D", "6A2C82", "7E4196", "8E51A6", "9C64B3", "A875BD", + "B88BC9", "C6A3D4", "D9C1E3", "E5D1ED", "EFE1F5", "FCF3FF"); + List FAIRY_HEXES = List.of("330066", "4C0099", "660033", "660066", "6600CC", "7F00FF", "99004C", "990099", "9933FF", "B266FF", + "CC0066", "CC00CC", "CC99FF", "E5CCFF", "FF007F", "FF00FF", "FF3399", "FF33FF", "FF66B2", "FF66FF", "FF99CC", "FF99FF", "FFCCE5", + "FFCCFF"); + List OG_FAIRY_HEXES = List.of("FF99FF", "FFCCFF", "E5CCFF", "CC99FF", "CC00CC", "FF00FF", "FF33FF", "FF66FF", + "B266FF", "9933FF", "7F00FF", "660066", "6600CC", "4C0099", "330066", "990099", "660033", "99004C", "CC0066", + "660033", "99004C", "FFCCE5", "660033", "FFCCE5", "FF99CC", "FFCCE5", "FF99CC", "FF66B2"); + List GLITCHED = List.of("FFDC51", "F7DA33", "606060", "E7413C", "45413C", "4A14B7", "1793C4", "000000", "E75C3C", "65605A", + "5D2FB9", "17A8C4", "E76E3C", "88837E", "8969C8", "1CD4E4"); // Glitched through other means such as Shark Scale upgrade color¬ + List SPOOK = List.of("000000", "070008", "0E000F", "150017", "1B001F", "220027", "29002E", "300036", "37003E", "3E0046", + "45004D", "4C0055", "52005D", "590065", "60006C", "670074", "6E007C", "750084", "7C008B", "830093", + "89009B", "9000A3", "9700AA", "993399", "9E00B2"); + + // List of exceptions + List RANCHERS = List.of("CC5500", "000000", "0"); + List REAPER = List.of("1B1B1B", "FF0000"); + List ADAPTIVE_CHEST = List.of("3ABE78", "82E3D8", "BFBCB2", "D579FF", "FF4242", "FFC234"); + List ADAPTIVE = List.of("169F57", "2AB5A5", "6E00A0", "BB0000", "BFBCB2", "FFF7E6"); } From 22cc85e70c50602eda53f1b5447c2fad0c11a5b1 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 16 Sep 2023 00:14:29 -0400 Subject: [PATCH 3/9] Rename CheckExotic --- .../hysky/skyblocker/skyblock/item/PriceInfoTooltip.java | 8 ++++---- .../item/exotic/{CheckExotic.java => ExoticCheck.java} | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/{CheckExotic.java => ExoticCheck.java} (99%) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java index 3ecbe8bed2..e8d619cd83 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -70,7 +70,7 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List lines, String internalID, NbtCompound nbt, String colorHex, String expectedHex, String existingTooltip) { - if (!colorHex.equalsIgnoreCase(expectedHex) && !CheckExotic.isException(internalID, colorHex) && !CheckExotic.intendedDyed(nbt)) { - final String type = CheckExotic.checkDyeType(colorHex); - lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + "(").append(CheckExotic.getTranslatedText(type).formatted(CheckExotic.getFormattingColor(type))).append(Formatting.DARK_GRAY + ")")); + if (!colorHex.equalsIgnoreCase(expectedHex) && !ExoticCheck.isException(internalID, colorHex) && !ExoticCheck.intendedDyed(nbt)) { + final String type = ExoticCheck.checkDyeType(colorHex); + lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + "(").append(ExoticCheck.getTranslatedText(type).formatted(ExoticCheck.getFormattingColor(type))).append(Formatting.DARK_GRAY + ")")); } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java similarity index 99% rename from src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java rename to src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java index c1b90f068e..6a8e51a595 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/CheckExotic.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java @@ -7,7 +7,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -public class CheckExotic { +public class ExoticCheck { public static String getExpectedHex(String id) { String color = PriceInfoTooltip.colorJson.get(id).getAsString(); if (color != null) { From 3a68bf3d435e1288a050f3db18c9fc61b7e23172 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 28 Oct 2023 13:14:37 -0400 Subject: [PATCH 4/9] Update files --- .../skyblocker/config/SkyblockerConfig.java | 5 +- .../config/categories/GeneralCategory.java | 7 + .../skyblock/item}/ExoticCheck.java | 5 +- .../skyblock/item/PriceInfoTooltip.java | 8 +- .../de/hysky/skyblocker/utils/Constants.java | 25 + .../skyblocker/config/SkyblockerConfig.java | 650 ------------------ .../xmrvizzy/skyblocker/utils/Constants.java | 33 - .../assets/skyblocker/lang/en_us.json | 2 +- 8 files changed, 42 insertions(+), 693 deletions(-) rename src/main/java/{me/xmrvizzy/skyblocker/skyblock/item/exotic => de/hysky/skyblocker/skyblock/item}/ExoticCheck.java (94%) delete mode 100644 src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java delete mode 100644 src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 8905644ff3..4959ca3b0e 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -178,7 +178,7 @@ public static class General { public FairySouls fairySouls = new FairySouls(); @SerialEntry - public MythologicalRitual mythologicalRitual = new MythologicalRitual(); + public MythologicalRitual mythologicalRitual = new MythologicalRitual(); @SerialEntry public ItemCooldown itemCooldown = new ItemCooldown(); @@ -485,6 +485,9 @@ public static class ItemTooltip { @SerialEntry public boolean enableMuseumDate = true; + + @SerialEntry + public boolean enableExoticCheck = true; } public static class ItemInfoDisplay { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 10b21891b8..8ce00172f6 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -356,6 +356,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.general.itemTooltip.enableMuseumDate = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck")) + .binding(defaults.general.itemTooltip.enableExoticCheck, + () -> config.general.itemTooltip.enableExoticCheck, + newValue -> config.general.itemTooltip.enableExoticCheck = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //Item Info Display diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java b/src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java similarity index 94% rename from src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java index 6a8e51a595..130ef04987 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/exotic/ExoticCheck.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java @@ -1,7 +1,6 @@ -package me.xmrvizzy.skyblocker.skyblock.item.exotic; +package de.hysky.skyblocker.skyblock.item; -import me.xmrvizzy.skyblocker.skyblock.item.PriceInfoTooltip; -import me.xmrvizzy.skyblocker.utils.Constants; +import de.hysky.skyblocker.utils.Constants; import net.minecraft.nbt.NbtCompound; import net.minecraft.text.MutableText; import net.minecraft.text.Text; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java index e8d619cd83..9e38f276a8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -4,7 +4,6 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.item.exotic.CheckExotic; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.ItemUtils; @@ -39,7 +38,6 @@ public class PriceInfoTooltip { private static JsonObject motesPricesJson; public static JsonObject colorJson; private static volatile boolean nullMsgSend = false; - private final static Gson gson = new Gson(); private static final Map apiAddresses; private static long npcHash = 0; private static long museumHash = 0; @@ -62,7 +60,7 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List motesPricesJson = downloadPrices("motes"))); - if (SkyblockerConfig.get().general.itemTooltip.enableExoticCheck && colorJson == null) + if (SkyblockerConfigManager.get().general.itemTooltip.enableExoticCheck && colorJson == null) futureList.add(CompletableFuture.runAsync(() -> colorJson = downloadPrices("color"))); minute++; - CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])) + CompletableFuture.allOf(futureList.toArray(CompletableFuture[]::new)) .whenComplete((unused, throwable) -> nullMsgSend = false); }, 1200, true); } diff --git a/src/main/java/de/hysky/skyblocker/utils/Constants.java b/src/main/java/de/hysky/skyblocker/utils/Constants.java index f144b51961..94eacf493e 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Constants.java +++ b/src/main/java/de/hysky/skyblocker/utils/Constants.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.utils; +import java.util.List; import java.util.function.IntFunction; import java.util.function.Supplier; import java.util.function.UnaryOperator; @@ -28,4 +29,28 @@ public interface Constants { .append(Text.literal("e").styled(WITH_COLOR.apply(0x12d5eb))) .append(Text.literal("r").styled(WITH_COLOR.apply(0x14d0ff))) .append(Text.literal("] ").formatted(Formatting.GRAY)); + + + List SEYMOUR_IDS = List.of("VELVET_TOP_HAT", "CASHMERE_JACKET", "SATIN_TROUSERS", "OXFORD_SHOES"); + + // Exotic Hexes + List CRYSTAL_HEXES = List.of("1F0030", "46085E", "54146E", "5D1C78", "63237D", "6A2C82", "7E4196", "8E51A6", "9C64B3", "A875BD", + "B88BC9", "C6A3D4", "D9C1E3", "E5D1ED", "EFE1F5", "FCF3FF"); + List FAIRY_HEXES = List.of("330066", "4C0099", "660033", "660066", "6600CC", "7F00FF", "99004C", "990099", "9933FF", "B266FF", + "CC0066", "CC00CC", "CC99FF", "E5CCFF", "FF007F", "FF00FF", "FF3399", "FF33FF", "FF66B2", "FF66FF", "FF99CC", "FF99FF", "FFCCE5", + "FFCCFF"); + List OG_FAIRY_HEXES = List.of("FF99FF", "FFCCFF", "E5CCFF", "CC99FF", "CC00CC", "FF00FF", "FF33FF", "FF66FF", + "B266FF", "9933FF", "7F00FF", "660066", "6600CC", "4C0099", "330066", "990099", "660033", "99004C", "CC0066", + "660033", "99004C", "FFCCE5", "660033", "FFCCE5", "FF99CC", "FFCCE5", "FF99CC", "FF66B2"); + List GLITCHED = List.of("FFDC51", "F7DA33", "606060", "E7413C", "45413C", "4A14B7", "1793C4", "000000", "E75C3C", "65605A", + "5D2FB9", "17A8C4", "E76E3C", "88837E", "8969C8", "1CD4E4"); // Glitched through other means such as Shark Scale upgrade color + List SPOOK = List.of("000000", "070008", "0E000F", "150017", "1B001F", "220027", "29002E", "300036", "37003E", "3E0046", + "45004D", "4C0055", "52005D", "590065", "60006C", "670074", "6E007C", "750084", "7C008B", "830093", + "89009B", "9000A3", "9700AA", "993399", "9E00B2"); + + // List of exceptions + List RANCHERS = List.of("CC5500", "000000", "0"); + List REAPER = List.of("1B1B1B", "FF0000"); + List ADAPTIVE_CHEST = List.of("3ABE78", "82E3D8", "BFBCB2", "D579FF", "FF4242", "FFC234"); + List ADAPTIVE = List.of("169F57", "2AB5A5", "6E00A0", "BB0000", "BFBCB2", "FFF7E6"); } diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java deleted file mode 100644 index 7fc042e5d6..0000000000 --- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java +++ /dev/null @@ -1,650 +0,0 @@ -package me.xmrvizzy.skyblocker.config; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.ConfigData; -import me.shedaniel.autoconfig.annotation.Config; -import me.shedaniel.autoconfig.annotation.ConfigEntry; -import me.shedaniel.autoconfig.serializer.ConfigSerializer; -import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; -import me.xmrvizzy.skyblocker.SkyblockerMod; -import me.xmrvizzy.skyblocker.skyblock.item.CustomArmorTrims; -import me.xmrvizzy.skyblocker.utils.chat.ChatFilterResult; -import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; - -import java.util.ArrayList; -import java.util.List; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - -@Config(name = "skyblocker") -public class SkyblockerConfig implements ConfigData { - - @ConfigEntry.Category("general") - @ConfigEntry.Gui.TransitiveObject - public General general = new General(); - - @ConfigEntry.Category("locations") - @ConfigEntry.Gui.TransitiveObject - public Locations locations = new Locations(); - - @ConfigEntry.Category("slayer") - @ConfigEntry.Gui.TransitiveObject - public Slayer slayer = new Slayer(); - - @ConfigEntry.Category("quickNav") - @ConfigEntry.Gui.TransitiveObject - public QuickNav quickNav = new QuickNav(); - - @ConfigEntry.Category("messages") - @ConfigEntry.Gui.TransitiveObject - public Messages messages = new Messages(); - - @ConfigEntry.Category("richPresence") - @ConfigEntry.Gui.TransitiveObject - public RichPresence richPresence = new RichPresence(); - - public static class QuickNav { - public boolean enableQuickNav = true; - - @ConfigEntry.Category("button1") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button1 = new QuickNavItem(true, new ItemData("diamond_sword"), "Your Skills", "/skills"); - - @ConfigEntry.Category("button2") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button2 = new QuickNavItem(true, new ItemData("painting"), "Collections", "/collection"); - - @ConfigEntry.Category("button3") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button3 = new QuickNavItem(true, new ItemData("bone"), "\\Pets \\(\\d+/\\d+\\)", "/pets"); - - @ConfigEntry.Category("button4") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button4 = new QuickNavItem(true, new ItemData("leather_chestplate", 1, "tag:{display:{color:8991416}}"), "Wardrobe \\([12]/2\\)", "/wardrobe"); - - @ConfigEntry.Category("button5") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button5 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-2081424676,-57521078,-2073572414,158072763],Properties:{textures:[{Value:\"ewogICJ0aW1lc3RhbXAiIDogMTU5MTMxMDU4NTYwOSwKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODBhMDc3ZTI0OGQxNDI3NzJlYTgwMDg2NGY4YzU3OGI5ZDM2ODg1YjI5ZGFmODM2YjY0YTcwNjg4MmI2ZWMxMCIKICAgIH0KICB9Cn0=\"}]}}}"), "Sack of Sacks", "/sacks"); - - @ConfigEntry.Category("button6") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button6 = new QuickNavItem(true, new ItemData("ender_chest"), "(?:Rift )?Storage(?: \\(1/2\\))?", "/storage"); - - @ConfigEntry.Category("button7") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button7 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-300151517,-631415889,-1193921967,-1821784279],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDdjYzY2ODc0MjNkMDU3MGQ1NTZhYzUzZTA2NzZjYjU2M2JiZGQ5NzE3Y2Q4MjY5YmRlYmVkNmY2ZDRlN2JmOCJ9fX0=\"}]}}}"), "none", "/hub"); - - @ConfigEntry.Category("button8") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button8 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;1605800870,415127827,-1236127084,15358548],Properties:{textures:[{Value:\"e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg5MWQ1YjI3M2ZmMGJjNTBjOTYwYjJjZDg2ZWVmMWM0MGExYjk0MDMyYWU3MWU3NTQ3NWE1NjhhODI1NzQyMSJ9fX0=\"}]}}}"), "none", "/warp dungeon_hub"); - - @ConfigEntry.Category("button9") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button9 = new QuickNavItem(true, new ItemData("player_head", 1, "tag:{SkullOwner:{Id:[I;-562285948,532499670,-1705302742,775653035],Properties:{textures:[{Value:\"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjVkZjU1NTkyNjQzMGQ1ZDc1YWRlZDIxZGQ5NjE5Yjc2YzViN2NhMmM3ZjU0MDE0NDA1MjNkNTNhOGJjZmFhYiJ9fX0=\"}]}}}"), "Visit prtl", "/visit prtl"); - - @ConfigEntry.Category("button10") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button10 = new QuickNavItem(true, new ItemData("enchanting_table"), "Enchant Item", "/etable"); - - @ConfigEntry.Category("button11") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button11 = new QuickNavItem(true, new ItemData("anvil"), "Anvil", "/anvil"); - - @ConfigEntry.Category("button12") - @ConfigEntry.Gui.CollapsibleObject() - public QuickNavItem button12 = new QuickNavItem(true, new ItemData("crafting_table"), "Craft Item", "/craft"); - } - - public static class QuickNavItem { - public QuickNavItem(Boolean render, ItemData itemData, String uiTitle, String clickEvent) { - this.render = render; - this.item = itemData; - this.clickEvent = clickEvent; - this.uiTitle = uiTitle; - } - - public Boolean render; - - @ConfigEntry.Category("item") - @ConfigEntry.Gui.CollapsibleObject() - public ItemData item; - - public String uiTitle; - public String clickEvent; - } - - public static class ItemData { - public ItemData(String itemName, int count, String nbt) { - this.itemName = itemName; - this.count = count; - this.nbt = nbt; - } - - public ItemData(String itemName) { - this.itemName = itemName; - this.count = 1; - this.nbt = ""; - } - - public String itemName; - public int count; - public String nbt; - } - - public static class General { - public boolean acceptReparty = true; - public boolean backpackPreviewWithoutShift = false; - public boolean hideEmptyTooltips = true; - public boolean hideStatusEffectOverlay = false; - - @ConfigEntry.Category("tabHud") - @ConfigEntry.Gui.CollapsibleObject() - public TabHudConf tabHud = new TabHudConf(); - - @ConfigEntry.Gui.Excluded - public String apiKey; - - @ConfigEntry.Category("bars") - @ConfigEntry.Gui.CollapsibleObject() - public Bars bars = new Bars(); - - @ConfigEntry.Category("experiments") - @ConfigEntry.Gui.CollapsibleObject() - public Experiments experiments = new Experiments(); - - @ConfigEntry.Category("fishing") - @ConfigEntry.Gui.CollapsibleObject() - public Fishing fishing = new Fishing(); - - @ConfigEntry.Category("fairySouls") - @ConfigEntry.Gui.CollapsibleObject() - public FairySouls fairySouls = new FairySouls(); - - @ConfigEntry.Category("shortcuts") - @ConfigEntry.Gui.CollapsibleObject() - public Shortcuts shortcuts = new Shortcuts(); - - @ConfigEntry.Category("quiverWarning") - @ConfigEntry.Gui.CollapsibleObject() - public QuiverWarning quiverWarning = new QuiverWarning(); - - @ConfigEntry.Category("itemList") - @ConfigEntry.Gui.CollapsibleObject() - public ItemList itemList = new ItemList(); - - @ConfigEntry.Category("itemTooltip") - @ConfigEntry.Gui.CollapsibleObject() - public ItemTooltip itemTooltip = new ItemTooltip(); - - @ConfigEntry.Category("itemInfoDisplay") - @ConfigEntry.Gui.CollapsibleObject - public ItemInfoDisplay itemInfoDisplay = new ItemInfoDisplay(); - - @ConfigEntry.Category("specialEffects") - @ConfigEntry.Gui.CollapsibleObject - public SpecialEffects specialEffects = new SpecialEffects(); - - @ConfigEntry.Category("hitbox") - @ConfigEntry.Gui.CollapsibleObject() - public Hitbox hitbox = new Hitbox(); - - @ConfigEntry.Gui.Tooltip() - @ConfigEntry.Category("titleContainer") - @ConfigEntry.Gui.CollapsibleObject() - public TitleContainer titleContainer = new TitleContainer(); - - @ConfigEntry.Category("Teleport Overlay") - @ConfigEntry.Gui.CollapsibleObject() - public TeleportOverlay teleportOverlay = new TeleportOverlay(); - - @ConfigEntry.Gui.Excluded - public List lockedSlots = new ArrayList<>(); - - @ConfigEntry.Gui.Excluded - public Object2ObjectOpenHashMap customItemNames = new Object2ObjectOpenHashMap<>(); - - @ConfigEntry.Gui.Excluded - public Object2IntOpenHashMap customDyeColors = new Object2IntOpenHashMap<>(); - - @ConfigEntry.Gui.Excluded - public Object2ObjectOpenHashMap customArmorTrims = new Object2ObjectOpenHashMap<>(); - } - - public static class TabHudConf { - public boolean tabHudEnabled = true; - - @ConfigEntry.BoundedDiscrete(min = 10, max = 200) - @ConfigEntry.Gui.Tooltip() - public int tabHudScale = 100; - @ConfigEntry.Gui.Tooltip - public boolean plainPlayerNames = false; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - @ConfigEntry.Gui.Tooltip - public NameSorting nameSorting = NameSorting.DEFAULT; - } - - public enum NameSorting { - DEFAULT, - ALPHABETICAL; - - @Override - public String toString() { - return switch (this) { - case DEFAULT -> "Default"; - case ALPHABETICAL -> "Alphabetical"; - }; - } - } - - public static class Bars { - public boolean enableBars = true; - - @ConfigEntry.Category("barpositions") - @ConfigEntry.Gui.CollapsibleObject() - public BarPositions barpositions = new BarPositions(); - } - - public static class BarPositions { - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public BarPosition healthBarPosition = BarPosition.LAYER1; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public BarPosition manaBarPosition = BarPosition.LAYER1; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public BarPosition defenceBarPosition = BarPosition.LAYER1; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public BarPosition experienceBarPosition = BarPosition.LAYER1; - - } - - public enum BarPosition { - LAYER1, - LAYER2, - RIGHT, - NONE; - - @Override - public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.general.bars.barpositions." + name()); - } - - public int toInt() { - return switch (this) { - case LAYER1 -> 0; - case LAYER2 -> 1; - case RIGHT -> 2; - case NONE -> -1; - }; - } - } - - public static class Experiments { - public boolean enableChronomatronSolver = true; - public boolean enableSuperpairsSolver = true; - public boolean enableUltrasequencerSolver = true; - } - - public static class Fishing { - public boolean enableFishingHelper = true; - } - - public static class FairySouls { - public boolean enableFairySoulsHelper = false; - } - - public static class Shortcuts { - @ConfigEntry.Gui.Tooltip() - public boolean enableShortcuts = true; - @ConfigEntry.Gui.Tooltip() - public boolean enableCommandShortcuts = true; - @ConfigEntry.Gui.Tooltip() - public boolean enableCommandArgShortcuts = true; - } - - public static class QuiverWarning { - public boolean enableQuiverWarning = true; - public boolean enableQuiverWarningInDungeons = true; - public boolean enableQuiverWarningAfterDungeon = true; - } - - public static class Hitbox { - public boolean oldFarmlandHitbox = true; - public boolean oldLeverHitbox = false; - } - - public static class TitleContainer { - @ConfigEntry.BoundedDiscrete(min = 30, max = 140) - public float titleContainerScale = 100; - public int x = 540; - public int y = 10; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public Direction direction = Direction.HORIZONTAL; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.DROPDOWN) - public Alignment alignment = Alignment.MIDDLE; - } - - public static class TeleportOverlay { - public boolean enableTeleportOverlays = true; - public boolean enableWeirdTransmission = true; - public boolean enableInstantTransmission = true; - public boolean enableEtherTransmission = true; - public boolean enableSinrecallTransmission = true; - public boolean enableWitherImpact = true; - } - - public enum Direction { - HORIZONTAL, - VERTICAL; - - @Override - public String toString() { - return switch (this) { - case HORIZONTAL -> "Horizontal"; - case VERTICAL -> "Vertical"; - }; - } - } - - public enum Alignment { - LEFT, - RIGHT, - MIDDLE; - - @Override - public String toString() { - return switch (this) { - case LEFT -> "Left"; - case RIGHT -> "Right"; - case MIDDLE -> "Middle"; - }; - } - } - - public static class RichPresence { - public boolean enableRichPresence = false; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - @ConfigEntry.Gui.Tooltip() - public Info info = Info.LOCATION; - public boolean cycleMode = false; - public String customMessage = "Playing Skyblock"; - } - - public static class ItemList { - public boolean enableItemList = true; - } - - public enum Average { - ONE_DAY, - THREE_DAY, - BOTH; - - @Override - public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.general.itemTooltip.avg." + name()); - } - } - - public static class ItemTooltip { - public boolean enableExoticCheck = true; - public boolean enableNPCPrice = true; - @ConfigEntry.Gui.Tooltip - public boolean enableMotesPrice = true; - public boolean enableAvgBIN = true; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - @ConfigEntry.Gui.Tooltip() - public Average avg = Average.THREE_DAY; - public boolean enableLowestBIN = true; - public boolean enableBazaarPrice = true; - public boolean enableMuseumDate = true; - } - - public static class ItemInfoDisplay { - @ConfigEntry.Gui.Tooltip - public boolean attributeShardInfo = true; - } - - public static class SpecialEffects { - @ConfigEntry.Gui.Tooltip - public boolean rareDungeonDropEffects = true; - } - - public static class Locations { - @ConfigEntry.Category("barn") - @ConfigEntry.Gui.CollapsibleObject() - public Barn barn = new Barn(); - - @ConfigEntry.Category("dungeons") - @ConfigEntry.Gui.CollapsibleObject() - public Dungeons dungeons = new Dungeons(); - - @ConfigEntry.Category("dwarvenmines") - @ConfigEntry.Gui.CollapsibleObject() - public DwarvenMines dwarvenMines = new DwarvenMines(); - - @ConfigEntry.Category("rift") - @ConfigEntry.Gui.CollapsibleObject() - public Rift rift = new Rift(); - } - - public static class Dungeons { - @ConfigEntry.Gui.CollapsibleObject - public SecretWaypoints secretWaypoints = new SecretWaypoints(); - @ConfigEntry.Gui.CollapsibleObject - public DungeonChestProfit dungeonChestProfit = new DungeonChestProfit(); - @ConfigEntry.Gui.Tooltip() - public boolean croesusHelper = true; - public boolean enableMap = true; - public float mapScaling = 1f; - public int mapX = 2; - public int mapY = 2; - @ConfigEntry.Gui.Tooltip - public boolean starredMobGlow = true; - public boolean solveThreeWeirdos = true; - @ConfigEntry.Gui.Tooltip - public boolean blazesolver = true; - public boolean solveTrivia = true; - @ConfigEntry.Gui.Tooltip - public boolean solveTicTacToe = true; - @ConfigEntry.Gui.CollapsibleObject - public LividColor lividColor = new LividColor(); - @ConfigEntry.Gui.CollapsibleObject() - public Terminals terminals = new Terminals(); - } - - public static class SecretWaypoints { - - public boolean enableSecretWaypoints = true; - @ConfigEntry.Gui.Tooltip() - public boolean noInitSecretWaypoints = false; - public boolean enableEntranceWaypoints = true; - public boolean enableSuperboomWaypoints = true; - public boolean enableChestWaypoints = true; - public boolean enableItemWaypoints = true; - public boolean enableBatWaypoints = true; - public boolean enableWitherWaypoints = true; - public boolean enableLeverWaypoints = true; - public boolean enableFairySoulWaypoints = true; - public boolean enableStonkWaypoints = true; - @ConfigEntry.Gui.Tooltip() - public boolean enableDefaultWaypoints = true; - } - - public static class DungeonChestProfit { - @ConfigEntry.Gui.Tooltip - public boolean enableProfitCalculator = true; - @ConfigEntry.Gui.Tooltip - public boolean includeKismet = false; - @ConfigEntry.Gui.Tooltip - public boolean includeEssence = true; - } - - public static class LividColor { - @ConfigEntry.Gui.Tooltip() - public boolean enableLividColor = true; - @ConfigEntry.Gui.Tooltip() - public String lividColorText = "The livid color is [color]"; - } - - public static class Terminals { - public boolean solveColor = true; - public boolean solveOrder = true; - public boolean solveStartsWith = true; - } - - public static class DwarvenMines { - public boolean enableDrillFuel = true; - public boolean solveFetchur = true; - public boolean solvePuzzler = true; - @ConfigEntry.Gui.CollapsibleObject() - public DwarvenHud dwarvenHud = new DwarvenHud(); - } - - public static class DwarvenHud { - public boolean enabled = true; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - @ConfigEntry.Gui.Tooltip(count = 3) - public DwarvenHudStyle style = DwarvenHudStyle.SIMPLE; - public boolean enableBackground = true; - public int x = 10; - public int y = 10; - } - - public enum DwarvenHudStyle { - SIMPLE, - FANCY, - CLASSIC; - - @Override - public String toString() { - return switch (this) { - case SIMPLE -> "Simple"; - case FANCY -> "Fancy"; - case CLASSIC -> "Classic"; - }; - } - } - - public static class Barn { - public boolean solveHungryHiker = true; - public boolean solveTreasureHunter = true; - } - - public static class Rift { - public boolean mirrorverseWaypoints = true; - @ConfigEntry.BoundedDiscrete(min = 0, max = 5) - @ConfigEntry.Gui.Tooltip - public int mcGrubberStacks = 0; - } - - public static class Slayer { - @ConfigEntry.Category("vampire") - @ConfigEntry.Gui.CollapsibleObject() - public VampireSlayer vampireSlayer = new VampireSlayer(); - } - - public static class VampireSlayer { - public boolean enableEffigyWaypoints = true; - public boolean compactEffigyWaypoints; - @ConfigEntry.BoundedDiscrete(min = 1, max = 10) - @ConfigEntry.Gui.Tooltip() - public int effigyUpdateFrequency = 5; - public boolean enableHolyIceIndicator = true; - public int holyIceIndicatorTickDelay = 10; - @ConfigEntry.BoundedDiscrete(min = 1, max = 10) - @ConfigEntry.Gui.Tooltip() - public int holyIceUpdateFrequency = 5; - public boolean enableHealingMelonIndicator = true; - public float healingMelonHealthThreshold = 4F; - public boolean enableSteakStakeIndicator = true; - @ConfigEntry.BoundedDiscrete(min = 1, max = 10) - @ConfigEntry.Gui.Tooltip() - public int steakStakeUpdateFrequency = 5; - public boolean enableManiaIndicator = true; - @ConfigEntry.BoundedDiscrete(min = 1, max = 10) - @ConfigEntry.Gui.Tooltip() - public int maniaUpdateFrequency = 5; - } - - public static class Messages { - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideAbility = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideHeal = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideAOTE = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideImplosion = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideMoltenWave = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideAds = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideTeleportPad = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideCombo = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ChatFilterResult hideAutopet = ChatFilterResult.PASS; - @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - @ConfigEntry.Gui.Tooltip - public ChatFilterResult hideShowOff = ChatFilterResult.PASS; - @ConfigEntry.Gui.Tooltip() - public boolean hideMana = false; - } - - public enum Info { - PURSE, - BITS, - LOCATION; - - @Override - public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.richPresence.info." + name()); - } - } - - /** - * Registers the config to AutoConfig and registers commands to open the config screen. - */ - public static void init() { - Gson gson = new GsonBuilder() - .setPrettyPrinting() - .registerTypeHierarchyAdapter(Text.class, new Text.Serializer()) - .registerTypeHierarchyAdapter(Style.class, new Style.Serializer()) - .registerTypeHierarchyAdapter(Identifier.class, new Identifier.Serializer()) - .create(); - - ConfigSerializer.Factory serializer = (cfg, cfgClass) -> new GsonConfigSerializer<>(cfg, cfgClass, gson); - - AutoConfig.register(SkyblockerConfig.class, serializer); - ClientCommandRegistrationCallback.EVENT.register(((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(optionsLiteral("config")).then(optionsLiteral("options"))))); - } - - /** - * Registers an options command with the given name. Used for registering both options and config as valid commands. - * - * @param name the name of the command node - * @return the command builder - */ - private static LiteralArgumentBuilder optionsLiteral(String name) { - // Don't immediately open the next screen as it will be closed by ChatScreen right after this command is executed - return literal(name).executes(Scheduler.queueOpenScreenCommand(AutoConfig.getConfigScreen(SkyblockerConfig.class, null))); - } - - public static SkyblockerConfig get() { - return AutoConfig.getConfigHolder(SkyblockerConfig.class).getConfig(); - } - - public static void save() { - AutoConfig.getConfigHolder(SkyblockerConfig.class).save(); - } -} diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java deleted file mode 100644 index a10e602550..0000000000 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/Constants.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.xmrvizzy.skyblocker.utils; - -import java.util.List; - -/** - * Holds generic static constants - */ -public interface Constants { - String LEVEL_EMBLEMS = "\u2E15\u273F\u2741\u2E19\u03B1\u270E\u2615\u2616\u2663\u213B\u2694\u27B6\u26A1\u2604\u269A\u2693\u2620\u269B\u2666\u2660\u2764\u2727\u238A\u1360\u262C\u269D\u29C9\uA214\u32D6\u2E0E\u26A0\uA541\u3020\u30C4\u2948\u2622\u2623\u273E\u269C\u0BD0\u0A6D\u2742\u16C3\u3023\u10F6\u0444\u266A\u266B\u04C3\u26C1\u26C3\u16DD\uA03E\u1C6A\u03A3\u09EB\u2603\u2654\u26C2\u12DE"; - - List SEYMOUR_IDS = List.of("VELVET_TOP_HAT", "CASHMERE_JACKET", "SATIN_TROUSERS", "OXFORD_SHOES"); - - // Exotic Hexes - List CRYSTAL_HEXES = List.of("1F0030", "46085E", "54146E", "5D1C78", "63237D", "6A2C82", "7E4196", "8E51A6", "9C64B3", "A875BD", - "B88BC9", "C6A3D4", "D9C1E3", "E5D1ED", "EFE1F5", "FCF3FF"); - List FAIRY_HEXES = List.of("330066", "4C0099", "660033", "660066", "6600CC", "7F00FF", "99004C", "990099", "9933FF", "B266FF", - "CC0066", "CC00CC", "CC99FF", "E5CCFF", "FF007F", "FF00FF", "FF3399", "FF33FF", "FF66B2", "FF66FF", "FF99CC", "FF99FF", "FFCCE5", - "FFCCFF"); - List OG_FAIRY_HEXES = List.of("FF99FF", "FFCCFF", "E5CCFF", "CC99FF", "CC00CC", "FF00FF", "FF33FF", "FF66FF", - "B266FF", "9933FF", "7F00FF", "660066", "6600CC", "4C0099", "330066", "990099", "660033", "99004C", "CC0066", - "660033", "99004C", "FFCCE5", "660033", "FFCCE5", "FF99CC", "FFCCE5", "FF99CC", "FF66B2"); - List GLITCHED = List.of("FFDC51", "F7DA33", "606060", "E7413C", "45413C", "4A14B7", "1793C4", "000000", "E75C3C", "65605A", - "5D2FB9", "17A8C4", "E76E3C", "88837E", "8969C8", "1CD4E4"); // Glitched through other means such as Shark Scale upgrade color¬ - List SPOOK = List.of("000000", "070008", "0E000F", "150017", "1B001F", "220027", "29002E", "300036", "37003E", "3E0046", - "45004D", "4C0055", "52005D", "590065", "60006C", "670074", "6E007C", "750084", "7C008B", "830093", - "89009B", "9000A3", "9700AA", "993399", "9E00B2"); - - // List of exceptions - List RANCHERS = List.of("CC5500", "000000", "0"); - List REAPER = List.of("1B1B1B", "FF0000"); - List ADAPTIVE_CHEST = List.of("3ABE78", "82E3D8", "BFBCB2", "D579FF", "FF4242", "FFC234"); - List ADAPTIVE = List.of("169F57", "2AB5A5", "6E00A0", "BB0000", "BFBCB2", "FFF7E6"); -} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 990fc35177..2373468b76 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -65,7 +65,6 @@ "text.autoconfig.skyblocker.option.general.tabHud.nameSorting": "Player Name Sorting Method", "text.autoconfig.skyblocker.option.general.tabHud.nameSorting.@Tooltip": "Alphabetical sorting sorts names alphabetically while Default has no particular order.", "text.autoconfig.skyblocker.option.general.itemTooltip": "Item Tooltip", - "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck": "Enable Exotic Check", "text.autoconfig.skyblocker.option.general.itemTooltip.enableNPCPrice": "Enable NPC Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice": "Enable Motes Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice.@Tooltip": "Displays the Motes sell price of an item while in The Rift.", @@ -78,6 +77,7 @@ "text.autoconfig.skyblocker.option.general.itemTooltip.enableLowestBIN": "Enable Lowest BIN Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableBazaarPrice": "Enable Bazaar buy/sell Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMuseumDate": "Enable Museum & Date", + "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck": "Enable Exotic Check", "text.autoconfig.skyblocker.option.general.itemInfoDisplay": "Item Info Display", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo": "Attribute Shard Info", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo.@Tooltip": "Displays the attribute's level as the stack count and the initials of the attribute's name.", From 14074ff48e377d26502047ca07b6e2b14bd2ca2d Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 01:12:49 -0400 Subject: [PATCH 5/9] Update ItemTooltip --- .../de/hysky/skyblocker/SkyblockerMod.java | 4 +- .../skyblocker/mixin/HandledScreenMixin.java | 2 + .../skyblocker/skyblock/TeleportOverlay.java | 4 +- .../skyblock/dungeon/DungeonChestProfit.java | 8 +- .../item/{ => tooltip}/BackpackPreview.java | 3 +- .../CompactorDeletorPreview.java | 2 +- .../CompactorPreviewTooltipComponent.java | 2 +- .../ExoticTooltip.java} | 63 ++-- .../ItemTooltip.java} | 304 +++++++++--------- .../java/de/hysky/skyblocker/utils/Utils.java | 4 +- 10 files changed, 214 insertions(+), 182 deletions(-) rename src/main/java/de/hysky/skyblocker/skyblock/item/{ => tooltip}/BackpackPreview.java (98%) rename src/main/java/de/hysky/skyblocker/skyblock/item/{ => tooltip}/CompactorDeletorPreview.java (98%) rename src/main/java/de/hysky/skyblocker/skyblock/item/{ => tooltip}/CompactorPreviewTooltipComponent.java (98%) rename src/main/java/de/hysky/skyblocker/skyblock/item/{ExoticCheck.java => tooltip/ExoticTooltip.java} (53%) rename src/main/java/de/hysky/skyblocker/skyblock/item/{PriceInfoTooltip.java => tooltip/ItemTooltip.java} (67%) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 5e23e2e2b5..5178a777dd 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -9,6 +9,8 @@ import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonSecrets; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud; import de.hysky.skyblocker.skyblock.item.*; +import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.skyblock.quicknav.QuickNav; import de.hysky.skyblocker.skyblock.rift.TheRift; @@ -73,7 +75,7 @@ public void onInitializeClient() { NEURepoManager.init(); ItemRepository.init(); HotbarSlotLock.init(); - PriceInfoTooltip.init(); + ItemTooltip.init(); WikiLookup.init(); FairySouls.init(); Relics.init(); diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java index 597faa3dd5..d7e5e824ab 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java @@ -7,6 +7,8 @@ import de.hysky.skyblocker.skyblock.experiment.SuperpairsSolver; import de.hysky.skyblocker.skyblock.experiment.UltrasequencerSolver; import de.hysky.skyblocker.skyblock.item.*; +import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; +import de.hysky.skyblocker.skyblock.item.tooltip.CompactorDeletorPreview; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java index 36e25d5c6e..c290e5b858 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.item.PriceInfoTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.RenderHelper; @@ -26,7 +26,7 @@ public static void init() { private static void render(WorldRenderContext wrc) { if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.teleportOverlay.enableTeleportOverlays && client.player != null && client.world != null) { ItemStack heldItem = client.player.getMainHandStack(); - String itemId = PriceInfoTooltip.getInternalNameFromNBT(heldItem, true); + String itemId = ItemTooltip.getInternalNameFromNBT(heldItem, true); NbtCompound extraAttributes = ItemUtils.getExtraAttributes(heldItem); if (itemId != null) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java index 4e6a524014..84d19f73c7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java @@ -4,7 +4,7 @@ import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.mixin.accessor.ScreenAccessor; -import de.hysky.skyblocker.skyblock.item.PriceInfoTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.utils.Utils; import it.unimi.dsi.fastutil.ints.IntBooleanPair; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; @@ -54,7 +54,7 @@ public static Text getChestProfit(GenericContainerScreenHandler handler, Text ti if (!stack.isEmpty()) { String name = stack.getName().getString(); - String id = PriceInfoTooltip.getInternalNameFromNBT(stack, false); + String id = ItemTooltip.getInternalNameFromNBT(stack, false); //Regular item price if (id != null) { @@ -128,8 +128,8 @@ public static Text getChestProfit(GenericContainerScreenHandler handler, Text ti * was based on complete data. */ private static IntBooleanPair getItemPrice(String id) { - JsonObject bazaarPrices = PriceInfoTooltip.getBazaarPrices(); - JsonObject lbinPrices = PriceInfoTooltip.getLBINPrices(); + JsonObject bazaarPrices = ItemTooltip.getBazaarPrices(); + JsonObject lbinPrices = ItemTooltip.getLBINPrices(); if (bazaarPrices == null || lbinPrices == null) return IntBooleanPair.of(0, false); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java index 8782440c94..5627b56d2f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/BackpackPreview.java @@ -1,8 +1,9 @@ -package de.hysky.skyblocker.skyblock.item; +package de.hysky.skyblocker.skyblock.item.tooltip; import com.mojang.blaze3d.systems.RenderSystem; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/CompactorDeletorPreview.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/skyblock/item/CompactorDeletorPreview.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java index 1e3dd7d25c..9cf0356bc3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/CompactorDeletorPreview.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorDeletorPreview.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.item; +package de.hysky.skyblocker.skyblock.item.tooltip; import de.hysky.skyblocker.mixin.accessor.DrawContextInvoker; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/CompactorPreviewTooltipComponent.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorPreviewTooltipComponent.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/skyblock/item/CompactorPreviewTooltipComponent.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorPreviewTooltipComponent.java index 513d7d7215..22498c0231 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/CompactorPreviewTooltipComponent.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/CompactorPreviewTooltipComponent.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.item; +package de.hysky.skyblocker.skyblock.item.tooltip; import de.hysky.skyblocker.SkyblockerMod; import it.unimi.dsi.fastutil.ints.IntIntPair; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java similarity index 53% rename from src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java index 130ef04987..8f70175870 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/ExoticCheck.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java @@ -1,20 +1,23 @@ -package de.hysky.skyblocker.skyblock.item; +package de.hysky.skyblocker.skyblock.item.tooltip; import de.hysky.skyblocker.utils.Constants; import net.minecraft.nbt.NbtCompound; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.StringIdentifiable; -public class ExoticCheck { +public class ExoticTooltip { public static String getExpectedHex(String id) { - String color = PriceInfoTooltip.colorJson.get(id).getAsString(); + if (!ItemTooltip.colorJson.has(id)) { + return null; + } + String color = ItemTooltip.colorJson.get(id).getAsString(); if (color != null) { String[] RGBValues = color.split(","); - String hex = String.format("%02x%02x%02x", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2])); - return hex.toUpperCase(); + return String.format("%02X%02X%02X", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2])); } else { - System.out.println("Color is null"); + ItemTooltip.LOGGER.warn("[Skyblocker Exotics] No expected color data found for id {}", id); return null; } } @@ -46,42 +49,50 @@ public static boolean isException(String id, String hex) { return false; } - public static String checkDyeType(String hex) { + public static DyeType checkDyeType(String hex) { if (Constants.CRYSTAL_HEXES.contains(hex)) { - return "CRYSTAL"; + return DyeType.CRYSTAL; } if (Constants.FAIRY_HEXES.contains(hex)) { - return "FAIRY"; + return DyeType.FAIRY; } if (Constants.OG_FAIRY_HEXES.contains(hex)) { - return "OG_FAIRY"; + return DyeType.OG_FAIRY; } if (Constants.SPOOK.contains(hex)) { - return "SPOOK"; + return DyeType.SPOOK; } if (Constants.GLITCHED.contains(hex)) { - return "GLITCHED"; + return DyeType.GLITCHED; } - return "EXOTIC"; + return DyeType.EXOTIC; } public static boolean intendedDyed(NbtCompound ItemData) { return ItemData.getCompound("ExtraAttributes").contains("dye_item"); } - public static Formatting getFormattingColor(String s) { - return switch (s) { - case "CRYSTAL" -> Formatting.AQUA; - case "FAIRY" -> Formatting.LIGHT_PURPLE; - case "OG_FAIRY" -> Formatting.DARK_PURPLE; - case "SPOOK" -> Formatting.RED; - case "GLITCHED" -> Formatting.BLUE; - case "EXOTIC" -> Formatting.GOLD; - default -> Formatting.DARK_GRAY; - }; - } + public enum DyeType implements StringIdentifiable { + CRYSTAL("crystal", Formatting.AQUA), + FAIRY("fairy", Formatting.LIGHT_PURPLE), + OG_FAIRY("og_fairy", Formatting.DARK_PURPLE), + SPOOK("spook", Formatting.RED), + GLITCHED("glitched", Formatting.BLUE), + EXOTIC("exotic", Formatting.GOLD); + private final String name; + private final Formatting formatting; + DyeType(String name, Formatting formatting) { + this.name = name; + this.formatting = formatting; + } - public static MutableText getTranslatedText(String s) { - return Text.translatable("skyblocker.exotic." + s.toLowerCase()); + @Override + public String asString() { + return name; + } + + public MutableText getTranslatedText() { + return Text.translatable("skyblocker.exotic." + name).formatted(formatting); + } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java similarity index 67% rename from src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java rename to src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java index 9e38f276a8..3c5e0b3336 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.skyblock.item; +package de.hysky.skyblocker.skyblock.item.tooltip; import com.google.gson.JsonObject; import de.hysky.skyblocker.SkyblockerMod; @@ -25,23 +25,23 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; -public class PriceInfoTooltip { - private static final Logger LOGGER = LoggerFactory.getLogger(PriceInfoTooltip.class.getName()); +public class ItemTooltip { + protected static final Logger LOGGER = LoggerFactory.getLogger(ItemTooltip.class.getName()); private static final MinecraftClient client = MinecraftClient.getInstance(); - private static JsonObject npcPricesJson; - private static JsonObject bazaarPricesJson; - private static JsonObject oneDayAvgPricesJson; - private static JsonObject threeDayAvgPricesJson; - private static JsonObject lowestPricesJson; - private static JsonObject isMuseumJson; - private static JsonObject motesPricesJson; - public static JsonObject colorJson; - private static volatile boolean nullMsgSend = false; - private static final Map apiAddresses; - private static long npcHash = 0; - private static long museumHash = 0; - private static long motesHash = 0; + private static final SkyblockerConfig.ItemTooltip config = SkyblockerConfigManager.get().general.itemTooltip; + private static final Map API_ADDRESSES = Map.of( + InfoType.NPC, "https://hysky.de/api/npcprice", + InfoType.BAZAAR, "https://hysky.de/api/bazaar", + InfoType.LOWEST_BINS, "https://hysky.de/api/auctions/lowestbins", + InfoType.ONE_DAY_AVERAGE, "https://moulberry.codes/auction_averages_lbin/1day.json", + InfoType.THREE_DAY_AVERAGE, "https://moulberry.codes/auction_averages_lbin/3day.json", + InfoType.MOTES, "https://hysky.de/api/motesprice", + InfoType.MUSEUM, "https://hysky.de/api/museum", + InfoType.COLOR, "https://hysky.de/api/color" + ); + private static volatile boolean sentNullWarning = false; public static void getTooltip(ItemStack stack, TooltipContext context, List lines) { if (!Utils.isOnSkyblock() || client.player == null) return; @@ -60,64 +60,22 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List each.getString().contains("Buy price:") || each.getString().contains("Sell price:")); - if (SkyblockerConfigManager.get().general.itemTooltip.enableNPCPrice) { - if (npcPricesJson == null) { - nullWarning(); - } else if (npcPricesJson.has(internalID)) { + if (InfoType.NPC.isEnabled(config)) { + if (InfoType.NPC.hasOrNullWarning(internalID)) { lines.add(Text.literal(String.format("%-21s", "NPC Price:")) .formatted(Formatting.YELLOW) - .append(getCoinsMessage(npcPricesJson.get(internalID).getAsDouble(), count))); - } - } - - if (SkyblockerConfigManager.get().general.itemTooltip.enableMotesPrice && Utils.isInTheRift()) { - if (motesPricesJson == null) { - nullWarning(); - } else if (motesPricesJson.has(internalID)) { - lines.add(Text.literal(String.format("%-20s", "Motes Price:")) - .formatted(Formatting.LIGHT_PURPLE) - .append(getMotesMessage(motesPricesJson.get(internalID).getAsInt(), count))); + .append(getCoinsMessage(InfoType.NPC.data.get(internalID).getAsDouble(), count))); } } boolean bazaarExist = false; - if (SkyblockerConfigManager.get().general.itemTooltip.enableBazaarPrice && !bazaarOpened) { - if (bazaarPricesJson == null) { - nullWarning(); - } else if (bazaarPricesJson.has(name)) { - JsonObject getItem = bazaarPricesJson.getAsJsonObject(name); + if (InfoType.BAZAAR.isEnabled(config) && !bazaarOpened) { + if (InfoType.BAZAAR.hasOrNullWarning(name)) { + JsonObject getItem = InfoType.BAZAAR.data.getAsJsonObject(name); lines.add(Text.literal(String.format("%-18s", "Bazaar buy Price:")) .formatted(Formatting.GOLD) .append(getItem.get("buyPrice").isJsonNull() @@ -134,19 +92,17 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List "%-18s"; + case "Armor" -> "%-19s"; + default -> "%-20s"; + }; + lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")")) + .formatted(Formatting.LIGHT_PURPLE) + .append(Text.literal(timestamp).formatted(Formatting.RED))); + } else if (!timestamp.isEmpty()) { + lines.add(Text.literal(String.format("%-21s", "Obtained: ")) + .formatted(Formatting.LIGHT_PURPLE) + .append(Text.literal(timestamp).formatted(Formatting.RED))); + } + } + + if (InfoType.COLOR.isEnabled(config)) { + if (InfoType.COLOR.data == null) { nullWarning(); - } else { - String timestamp = getTimestamp(stack); - - if (isMuseumJson.has(internalID)) { - String itemCategory = isMuseumJson.get(internalID).getAsString(); - String format = switch (itemCategory) { - case "Weapons" -> "%-18s"; - case "Armor" -> "%-19s"; - default -> "%-20s"; - }; - lines.add(Text.literal(String.format(format, "Museum: (" + itemCategory + ")")) - .formatted(Formatting.LIGHT_PURPLE) - .append(Text.literal(timestamp).formatted(Formatting.RED))); - } else if (!timestamp.isEmpty()) { - lines.add(Text.literal(String.format("%-21s", "Obtained: ")) - .formatted(Formatting.LIGHT_PURPLE) - .append(Text.literal(timestamp).formatted(Formatting.RED))); + } else if (stack.getNbt() != null) { + final NbtElement color = stack.getNbt().getCompound("display").get("color"); + + if (color != null) { + String colorHex = String.format("%06X", Integer.parseInt(color.asString())); + String expectedHex = ExoticTooltip.getExpectedHex(internalID); + + boolean correctLine = false; + for (Text text : lines) { + String existingTooltip = text.getString() + " "; + if (existingTooltip.startsWith("Color: ")) { + correctLine = true; + + addExoticTooltip(lines, internalID, stack.getNbt(), colorHex, expectedHex, existingTooltip); + break; + } + } + + if (!correctLine) { + addExoticTooltip(lines, internalID, stack.getNbt(), colorHex, expectedHex, ""); + } } } } } private static void addExoticTooltip(List lines, String internalID, NbtCompound nbt, String colorHex, String expectedHex, String existingTooltip) { - if (!colorHex.equalsIgnoreCase(expectedHex) && !ExoticCheck.isException(internalID, colorHex) && !ExoticCheck.intendedDyed(nbt)) { - final String type = ExoticCheck.checkDyeType(colorHex); - lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + "(").append(ExoticCheck.getTranslatedText(type).formatted(ExoticCheck.getFormattingColor(type))).append(Formatting.DARK_GRAY + ")")); + if (expectedHex != null && !colorHex.equalsIgnoreCase(expectedHex) && !ExoticTooltip.isException(internalID, colorHex) && !ExoticTooltip.intendedDyed(nbt)) { + final ExoticTooltip.DyeType type = ExoticTooltip.checkDyeType(colorHex); + lines.add(1, Text.literal(existingTooltip + Formatting.DARK_GRAY + "(").append(type.getTranslatedText()).append(Formatting.DARK_GRAY + ")")); } } private static void nullWarning() { - if (!nullMsgSend && client.player != null) { + if (!sentNullWarning && client.player != null) { client.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemTooltip.nullMessage")), false); - nullMsgSend = true; + sentNullWarning = true; } } @@ -380,90 +368,118 @@ private static Text getMotesMessage(int price, int count) { public static void init() { Scheduler.INSTANCE.scheduleCyclic(() -> { if (!Utils.isOnSkyblock() && 0 < minute++) { - nullMsgSend = false; + sentNullWarning = false; return; } List> futureList = new ArrayList<>(); - if (SkyblockerConfigManager.get().general.itemTooltip.enableAvgBIN) { - SkyblockerConfig.Average type = SkyblockerConfigManager.get().general.itemTooltip.avg; - if (type == SkyblockerConfig.Average.BOTH || oneDayAvgPricesJson == null || threeDayAvgPricesJson == null || minute % 5 == 0) { + if (InfoType.NPC.isEnabled(config) && InfoType.NPC.data == null) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.NPC))); + + if (InfoType.BAZAAR.isEnabled(config) || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.BAZAAR))); + + if (InfoType.LOWEST_BINS.isEnabled(config) || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.LOWEST_BINS))); + + if (config.enableAvgBIN) { + SkyblockerConfig.Average type = config.avg; + + if (type == SkyblockerConfig.Average.BOTH || InfoType.ONE_DAY_AVERAGE.data == null || InfoType.THREE_DAY_AVERAGE.data == null || minute % 5 == 0) { futureList.add(CompletableFuture.runAsync(() -> { - oneDayAvgPricesJson = downloadPrices("1 day avg"); - threeDayAvgPricesJson = downloadPrices("3 day avg"); + downloadPrices(InfoType.ONE_DAY_AVERAGE); + downloadPrices(InfoType.THREE_DAY_AVERAGE); })); } else if (type == SkyblockerConfig.Average.ONE_DAY) { - futureList.add(CompletableFuture.runAsync(() -> oneDayAvgPricesJson = downloadPrices("1 day avg"))); + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.ONE_DAY_AVERAGE))); } else if (type == SkyblockerConfig.Average.THREE_DAY) { - futureList.add(CompletableFuture.runAsync(() -> threeDayAvgPricesJson = downloadPrices("3 day avg"))); + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.THREE_DAY_AVERAGE))); } } - if (SkyblockerConfigManager.get().general.itemTooltip.enableLowestBIN || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) - futureList.add(CompletableFuture.runAsync(() -> lowestPricesJson = downloadPrices("lowest bins"))); - - if (SkyblockerConfigManager.get().general.itemTooltip.enableBazaarPrice || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) - futureList.add(CompletableFuture.runAsync(() -> bazaarPricesJson = downloadPrices("bazaar"))); - - if (SkyblockerConfigManager.get().general.itemTooltip.enableNPCPrice && npcPricesJson == null) - futureList.add(CompletableFuture.runAsync(() -> npcPricesJson = downloadPrices("npc"))); - if (SkyblockerConfigManager.get().general.itemTooltip.enableMuseumDate && isMuseumJson == null) - futureList.add(CompletableFuture.runAsync(() -> isMuseumJson = downloadPrices("museum"))); + if (InfoType.MOTES.isEnabled(config) && InfoType.MOTES.data == null) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.MOTES))); - if (SkyblockerConfigManager.get().general.itemTooltip.enableMotesPrice && motesPricesJson == null) - futureList.add(CompletableFuture.runAsync(() -> motesPricesJson = downloadPrices("motes"))); + if (InfoType.MUSEUM.isEnabled(config) && InfoType.MUSEUM.data == null) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.MUSEUM))); - if (SkyblockerConfigManager.get().general.itemTooltip.enableExoticCheck && colorJson == null) - futureList.add(CompletableFuture.runAsync(() -> colorJson = downloadPrices("color"))); + if (InfoType.COLOR.isEnabled(config) && InfoType.COLOR.data == null) + futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.COLOR))); minute++; CompletableFuture.allOf(futureList.toArray(CompletableFuture[]::new)) - .whenComplete((unused, throwable) -> nullMsgSend = false); + .whenComplete((unused, throwable) -> sentNullWarning = false); }, 1200, true); } - private static JsonObject downloadPrices(String type) { + private static void downloadPrices(InfoType type) { try { - String url = apiAddresses.get(type); + String url = API_ADDRESSES.get(type); - if (type.equals("npc") || type.equals("museum") || type.equals("motes")) { + if (type.cacheable) { HttpHeaders headers = Http.sendHeadRequest(url); long combinedHash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); switch (type) { - case "npc": if (npcHash == combinedHash) return npcPricesJson; else npcHash = combinedHash; - case "museum": if (museumHash == combinedHash) return isMuseumJson; else museumHash = combinedHash; - case "motes": if (motesHash == combinedHash) return motesPricesJson; else motesHash = combinedHash; + case NPC, MOTES, MUSEUM, COLOR: + if (type.hash == combinedHash) return; + else type.hash = combinedHash; } } - String apiResponse = Http.sendGetRequest(url); - - return SkyblockerMod.GSON.fromJson(apiResponse, JsonObject.class); + type.setData(SkyblockerMod.GSON.fromJson(Http.sendGetRequest(url), JsonObject.class)); } catch (Exception e) { LOGGER.warn("[Skyblocker] Failed to download " + type + " prices!", e); - return null; } } public static JsonObject getBazaarPrices() { - return bazaarPricesJson; + return InfoType.BAZAAR.data; } public static JsonObject getLBINPrices() { - return lowestPricesJson; + return InfoType.LOWEST_BINS.data; } - static { - apiAddresses = new HashMap<>(); - apiAddresses.put("1 day avg", "https://moulberry.codes/auction_averages_lbin/1day.json"); - apiAddresses.put("3 day avg", "https://moulberry.codes/auction_averages_lbin/3day.json"); - apiAddresses.put("bazaar", "https://hysky.de/api/bazaar"); - apiAddresses.put("lowest bins", "https://hysky.de/api/auctions/lowestbins"); - apiAddresses.put("npc", "https://hysky.de/api/npcprice"); - apiAddresses.put("museum", "https://hysky.de/api/museum"); - apiAddresses.put("motes", "https://hysky.de/api/motesprice"); - apiAddresses.put("color", "https://hysky.de/api/color"); + public enum InfoType { + NPC(itemTooltip -> itemTooltip.enableNPCPrice, true), + BAZAAR(itemTooltip -> itemTooltip.enableBazaarPrice, false), + LOWEST_BINS(itemTooltip -> itemTooltip.enableLowestBIN, false), + ONE_DAY_AVERAGE(itemTooltip -> itemTooltip.enableAvgBIN, false), + THREE_DAY_AVERAGE(itemTooltip -> itemTooltip.enableAvgBIN, false), + MOTES(itemTooltip -> itemTooltip.enableMotesPrice, true), + MUSEUM(itemTooltip -> itemTooltip.enableMuseumDate, true), + COLOR(itemTooltip -> itemTooltip.enableExoticCheck, true); + + private final Predicate enabledPredicate; + private JsonObject data; + private final boolean cacheable; + private long hash; + + InfoType(Predicate enabledPredicate, boolean cacheable) { + this(enabledPredicate, null, false); + } + + InfoType(Predicate enabledPredicate, JsonObject data, boolean cacheable) { + this.enabledPredicate = enabledPredicate; + this.data = data; + this.cacheable = cacheable; + } + + public boolean isEnabled(SkyblockerConfig.ItemTooltip config) { + return enabledPredicate.test(config); + } + + public boolean hasOrNullWarning(String memberName) { + if (data == null) { + nullWarning(); + return false; + } else return data.has(memberName); + } + + public void setData(JsonObject data) { + this.data = data; + } } } \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index 0f87e8c448..b1a347f986 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -4,7 +4,7 @@ import com.google.gson.JsonParser; import de.hysky.skyblocker.events.SkyblockEvents; import de.hysky.skyblocker.skyblock.item.MuseumItemCache; -import de.hysky.skyblocker.skyblock.item.PriceInfoTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.rift.TheRift; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -180,7 +180,7 @@ public static void updatePlayerPresenceFromScoreboard(MinecraftClient client) { if (!isOnSkyblock) { if (!isInjected) { isInjected = true; - ItemTooltipCallback.EVENT.register(PriceInfoTooltip::getTooltip); + ItemTooltipCallback.EVENT.register(ItemTooltip::getTooltip); } isOnSkyblock = true; SkyblockEvents.JOIN.invoker().onSkyblockJoin(); From b251cb353b85fa48e59ed35b3c7f866f6f403a93 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:09:15 -0400 Subject: [PATCH 6/9] Add TooltipInfoType --- .../skyblock/dungeon/DungeonChestProfit.java | 5 +- .../skyblock/item/tooltip/ExoticTooltip.java | 5 +- .../skyblock/item/tooltip/ItemTooltip.java | 238 +++++------------- .../item/tooltip/TooltipInfoType.java | 154 ++++++++++++ 4 files changed, 224 insertions(+), 178 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java index 84d19f73c7..1e889af362 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonChestProfit.java @@ -5,6 +5,7 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.mixin.accessor.ScreenAccessor; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; import de.hysky.skyblocker.utils.Utils; import it.unimi.dsi.fastutil.ints.IntBooleanPair; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; @@ -128,8 +129,8 @@ public static Text getChestProfit(GenericContainerScreenHandler handler, Text ti * was based on complete data. */ private static IntBooleanPair getItemPrice(String id) { - JsonObject bazaarPrices = ItemTooltip.getBazaarPrices(); - JsonObject lbinPrices = ItemTooltip.getLBINPrices(); + JsonObject bazaarPrices = TooltipInfoType.BAZAAR.getData(); + JsonObject lbinPrices = TooltipInfoType.LOWEST_BINS.getData(); if (bazaarPrices == null || lbinPrices == null) return IntBooleanPair.of(0, false); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java index 8f70175870..55a91392aa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java @@ -9,10 +9,7 @@ public class ExoticTooltip { public static String getExpectedHex(String id) { - if (!ItemTooltip.colorJson.has(id)) { - return null; - } - String color = ItemTooltip.colorJson.get(id).getAsString(); + String color = TooltipInfoType.COLOR.getData().get(id).getAsString(); if (color != null) { String[] RGBValues = color.split(","); return String.format("%02X%02X%02X", Integer.parseInt(RGBValues[0]), Integer.parseInt(RGBValues[1]), Integer.parseInt(RGBValues[2])); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java index 3c5e0b3336..e050aff50b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java @@ -5,7 +5,6 @@ import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Constants; -import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; @@ -20,27 +19,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.http.HttpHeaders; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; public class ItemTooltip { protected static final Logger LOGGER = LoggerFactory.getLogger(ItemTooltip.class.getName()); private static final MinecraftClient client = MinecraftClient.getInstance(); - private static final SkyblockerConfig.ItemTooltip config = SkyblockerConfigManager.get().general.itemTooltip; - private static final Map API_ADDRESSES = Map.of( - InfoType.NPC, "https://hysky.de/api/npcprice", - InfoType.BAZAAR, "https://hysky.de/api/bazaar", - InfoType.LOWEST_BINS, "https://hysky.de/api/auctions/lowestbins", - InfoType.ONE_DAY_AVERAGE, "https://moulberry.codes/auction_averages_lbin/1day.json", - InfoType.THREE_DAY_AVERAGE, "https://moulberry.codes/auction_averages_lbin/3day.json", - InfoType.MOTES, "https://hysky.de/api/motesprice", - InfoType.MUSEUM, "https://hysky.de/api/museum", - InfoType.COLOR, "https://hysky.de/api/color" - ); + protected static final SkyblockerConfig.ItemTooltip config = SkyblockerConfigManager.get().general.itemTooltip; private static volatile boolean sentNullWarning = false; public static void getTooltip(ItemStack stack, TooltipContext context, List lines) { @@ -63,46 +50,40 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List each.getString().contains("Buy price:") || each.getString().contains("Sell price:")); - if (InfoType.NPC.isEnabled(config)) { - if (InfoType.NPC.hasOrNullWarning(internalID)) { - lines.add(Text.literal(String.format("%-21s", "NPC Price:")) - .formatted(Formatting.YELLOW) - .append(getCoinsMessage(InfoType.NPC.data.get(internalID).getAsDouble(), count))); - } + if (TooltipInfoType.NPC.isTooltipEnabledAndHasOrNullWarning(internalID)) { + lines.add(Text.literal(String.format("%-21s", "NPC Price:")) + .formatted(Formatting.YELLOW) + .append(getCoinsMessage(TooltipInfoType.NPC.getData().get(internalID).getAsDouble(), count))); } boolean bazaarExist = false; - if (InfoType.BAZAAR.isEnabled(config) && !bazaarOpened) { - if (InfoType.BAZAAR.hasOrNullWarning(name)) { - JsonObject getItem = InfoType.BAZAAR.data.getAsJsonObject(name); - lines.add(Text.literal(String.format("%-18s", "Bazaar buy Price:")) - .formatted(Formatting.GOLD) - .append(getItem.get("buyPrice").isJsonNull() - ? Text.literal("No data").formatted(Formatting.RED) - : getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); - lines.add(Text.literal(String.format("%-19s", "Bazaar sell Price:")) - .formatted(Formatting.GOLD) - .append(getItem.get("sellPrice").isJsonNull() - ? Text.literal("No data").formatted(Formatting.RED) - : getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); - bazaarExist = true; - } + if (TooltipInfoType.BAZAAR.isTooltipEnabledAndHasOrNullWarning(name) && !bazaarOpened) { + JsonObject getItem = TooltipInfoType.BAZAAR.getData().getAsJsonObject(name); + lines.add(Text.literal(String.format("%-18s", "Bazaar buy Price:")) + .formatted(Formatting.GOLD) + .append(getItem.get("buyPrice").isJsonNull() + ? Text.literal("No data").formatted(Formatting.RED) + : getCoinsMessage(getItem.get("buyPrice").getAsDouble(), count))); + lines.add(Text.literal(String.format("%-19s", "Bazaar sell Price:")) + .formatted(Formatting.GOLD) + .append(getItem.get("sellPrice").isJsonNull() + ? Text.literal("No data").formatted(Formatting.RED) + : getCoinsMessage(getItem.get("sellPrice").getAsDouble(), count))); + bazaarExist = true; } // bazaarOpened & bazaarExist check for lbin, because Skytils keeps some bazaar item data in lbin api boolean lbinExist = false; - if (InfoType.LOWEST_BINS.isEnabled(config) && !bazaarOpened && !bazaarExist) { - if (InfoType.LOWEST_BINS.hasOrNullWarning(name)) { - lines.add(Text.literal(String.format("%-19s", "Lowest BIN Price:")) - .formatted(Formatting.GOLD) - .append(getCoinsMessage(InfoType.LOWEST_BINS.data.get(name).getAsDouble(), count))); - lbinExist = true; - } + if (TooltipInfoType.LOWEST_BINS.isTooltipEnabledAndHasOrNullWarning(name) && !bazaarOpened && !bazaarExist) { + lines.add(Text.literal(String.format("%-19s", "Lowest BIN Price:")) + .formatted(Formatting.GOLD) + .append(getCoinsMessage(TooltipInfoType.LOWEST_BINS.getData().get(name).getAsDouble(), count))); + lbinExist = true; } if (SkyblockerConfigManager.get().general.itemTooltip.enableAvgBIN) { - if (InfoType.ONE_DAY_AVERAGE.data == null || InfoType.THREE_DAY_AVERAGE.data == null) { + if (TooltipInfoType.ONE_DAY_AVERAGE.getData() == null || TooltipInfoType.THREE_DAY_AVERAGE.getData() == null) { nullWarning(); } else { /* @@ -139,9 +120,9 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List "%-18s"; case "Armor" -> "%-19s"; @@ -187,31 +166,27 @@ public static void getTooltip(ItemStack stack, TooltipContext context, List lines, String internalID, NbtCom } } - private static void nullWarning() { + public static void nullWarning() { if (!sentNullWarning && client.player != null) { client.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemTooltip.nullMessage")), false); sentNullWarning = true; @@ -262,6 +237,7 @@ public static String getTimestamp(ItemStack stack) { return ""; } + // TODO What in the world is this? public static String getInternalNameFromNBT(ItemStack stack, boolean internalIDOnly) { NbtCompound ea = ItemUtils.getExtraAttributes(stack); @@ -374,112 +350,30 @@ public static void init() { List> futureList = new ArrayList<>(); - if (InfoType.NPC.isEnabled(config) && InfoType.NPC.data == null) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.NPC))); - - if (InfoType.BAZAAR.isEnabled(config) || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.BAZAAR))); - - if (InfoType.LOWEST_BINS.isEnabled(config) || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.LOWEST_BINS))); + TooltipInfoType.NPC.downloadIfEnabled(futureList); + TooltipInfoType.BAZAAR.downloadIfEnabled(futureList); + TooltipInfoType.LOWEST_BINS.downloadIfEnabled(futureList); if (config.enableAvgBIN) { SkyblockerConfig.Average type = config.avg; - if (type == SkyblockerConfig.Average.BOTH || InfoType.ONE_DAY_AVERAGE.data == null || InfoType.THREE_DAY_AVERAGE.data == null || minute % 5 == 0) { - futureList.add(CompletableFuture.runAsync(() -> { - downloadPrices(InfoType.ONE_DAY_AVERAGE); - downloadPrices(InfoType.THREE_DAY_AVERAGE); - })); + if (type == SkyblockerConfig.Average.BOTH || TooltipInfoType.ONE_DAY_AVERAGE.getData() == null || TooltipInfoType.THREE_DAY_AVERAGE.getData() == null || minute % 5 == 0) { + TooltipInfoType.ONE_DAY_AVERAGE.download(futureList); + TooltipInfoType.THREE_DAY_AVERAGE.download(futureList); } else if (type == SkyblockerConfig.Average.ONE_DAY) { - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.ONE_DAY_AVERAGE))); + TooltipInfoType.ONE_DAY_AVERAGE.download(futureList); } else if (type == SkyblockerConfig.Average.THREE_DAY) { - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.THREE_DAY_AVERAGE))); + TooltipInfoType.THREE_DAY_AVERAGE.download(futureList); } } - if (InfoType.MOTES.isEnabled(config) && InfoType.MOTES.data == null) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.MOTES))); - - if (InfoType.MUSEUM.isEnabled(config) && InfoType.MUSEUM.data == null) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.MUSEUM))); - - if (InfoType.COLOR.isEnabled(config) && InfoType.COLOR.data == null) - futureList.add(CompletableFuture.runAsync(() -> downloadPrices(InfoType.COLOR))); + TooltipInfoType.MOTES.downloadIfEnabled(futureList); + TooltipInfoType.MUSEUM.downloadIfEnabled(futureList); + TooltipInfoType.COLOR.downloadIfEnabled(futureList); minute++; CompletableFuture.allOf(futureList.toArray(CompletableFuture[]::new)) .whenComplete((unused, throwable) -> sentNullWarning = false); }, 1200, true); } - - private static void downloadPrices(InfoType type) { - try { - String url = API_ADDRESSES.get(type); - - if (type.cacheable) { - HttpHeaders headers = Http.sendHeadRequest(url); - long combinedHash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); - - switch (type) { - case NPC, MOTES, MUSEUM, COLOR: - if (type.hash == combinedHash) return; - else type.hash = combinedHash; - } - } - - type.setData(SkyblockerMod.GSON.fromJson(Http.sendGetRequest(url), JsonObject.class)); - } catch (Exception e) { - LOGGER.warn("[Skyblocker] Failed to download " + type + " prices!", e); - } - } - - public static JsonObject getBazaarPrices() { - return InfoType.BAZAAR.data; - } - - public static JsonObject getLBINPrices() { - return InfoType.LOWEST_BINS.data; - } - - public enum InfoType { - NPC(itemTooltip -> itemTooltip.enableNPCPrice, true), - BAZAAR(itemTooltip -> itemTooltip.enableBazaarPrice, false), - LOWEST_BINS(itemTooltip -> itemTooltip.enableLowestBIN, false), - ONE_DAY_AVERAGE(itemTooltip -> itemTooltip.enableAvgBIN, false), - THREE_DAY_AVERAGE(itemTooltip -> itemTooltip.enableAvgBIN, false), - MOTES(itemTooltip -> itemTooltip.enableMotesPrice, true), - MUSEUM(itemTooltip -> itemTooltip.enableMuseumDate, true), - COLOR(itemTooltip -> itemTooltip.enableExoticCheck, true); - - private final Predicate enabledPredicate; - private JsonObject data; - private final boolean cacheable; - private long hash; - - InfoType(Predicate enabledPredicate, boolean cacheable) { - this(enabledPredicate, null, false); - } - - InfoType(Predicate enabledPredicate, JsonObject data, boolean cacheable) { - this.enabledPredicate = enabledPredicate; - this.data = data; - this.cacheable = cacheable; - } - - public boolean isEnabled(SkyblockerConfig.ItemTooltip config) { - return enabledPredicate.test(config); - } - - public boolean hasOrNullWarning(String memberName) { - if (data == null) { - nullWarning(); - return false; - } else return data.has(memberName); - } - - public void setData(JsonObject data) { - this.data = data; - } - } } \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java new file mode 100644 index 0000000000..ddc8bd1cef --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -0,0 +1,154 @@ +package de.hysky.skyblocker.skyblock.item.tooltip; + +import com.google.gson.JsonObject; +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfig; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Http; +import de.hysky.skyblocker.utils.Utils; +import org.jetbrains.annotations.Nullable; + +import java.net.http.HttpHeaders; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; + +public enum TooltipInfoType implements Runnable { + NPC("https://hysky.de/api/npcprice", itemTooltip -> itemTooltip.enableNPCPrice, true), + BAZAAR("https://hysky.de/api/bazaar", itemTooltip -> itemTooltip.enableBazaarPrice || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator, itemTooltip -> itemTooltip.enableBazaarPrice, false), + LOWEST_BINS("https://hysky.de/api/auctions/lowestbins", itemTooltip -> itemTooltip.enableLowestBIN || SkyblockerConfigManager.get().locations.dungeons.dungeonChestProfit.enableProfitCalculator, itemTooltip -> itemTooltip.enableLowestBIN, false), + ONE_DAY_AVERAGE("https://moulberry.codes/auction_averages_lbin/1day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), + THREE_DAY_AVERAGE("https://moulberry.codes/auction_averages_lbin/3day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), + MOTES("https://hysky.de/api/motesprice", itemTooltip -> itemTooltip.enableMotesPrice, itemTooltip -> itemTooltip.enableMotesPrice && Utils.isInTheRift(), true), + MUSEUM("https://hysky.de/api/museum", itemTooltip -> itemTooltip.enableMuseumDate, true), + COLOR("https://hysky.de/api/color", itemTooltip -> itemTooltip.enableExoticCheck, true); + + private final String address; + private final Predicate dataEnabled; + private final Predicate tooltipEnabled; + private JsonObject data; + private final boolean cacheable; + private long hash; + + /** + * @param address the address to download the data from + * @param enabled the predicate to check if the data should be downloaded and the tooltip should be shown + * @param cacheable whether the data should be cached + */ + TooltipInfoType(String address, Predicate enabled, boolean cacheable) { + this(address, enabled, enabled, null, cacheable); + } + + /** + * @param address the address to download the data from + * @param dataEnabled the predicate to check if data should be downloaded + * @param tooltipEnabled the predicate to check if the tooltip should be shown + * @param cacheable whether the data should be cached + */ + TooltipInfoType(String address, Predicate dataEnabled, Predicate tooltipEnabled, boolean cacheable) { + this(address, dataEnabled, tooltipEnabled, null, cacheable); + } + + /** + * @param address the address to download the data from + * @param dataEnabled the predicate to check if data should be downloaded + * @param tooltipEnabled the predicate to check if the tooltip should be shown + * @param data the data + * @param cacheable whether the data should be cached + */ + TooltipInfoType(String address, Predicate dataEnabled, Predicate tooltipEnabled, @Nullable JsonObject data, boolean cacheable) { + this.address = address; + this.dataEnabled = dataEnabled; + this.tooltipEnabled = tooltipEnabled; + this.data = data; + this.cacheable = cacheable; + } + + /** + * @return whether the data should be downloaded + */ + private boolean isDataEnabled() { + return dataEnabled.test(ItemTooltip.config); + } + + /** + * @return whether the tooltip should be shown + */ + public boolean isTooltipEnabled() { + return tooltipEnabled.test(ItemTooltip.config); + } + + public JsonObject getData() { + return data; + } + + public void setData(JsonObject data) { + this.data = data; + } + + /** + * Checks if the data has the given member name and sends a warning message if data is null. + * + * @param memberName the member name to check + * @return whether the data has the given member name or not + */ + public boolean hasOrNullWarning(String memberName) { + if (data == null) { + ItemTooltip.nullWarning(); + return false; + } else return data.has(memberName); + } + + /** + * Checks if the tooltip is enabled and the data has the given member name and sends a warning message if data is null. + * + * @param memberName the member name to check + * @return whether the tooltip is enabled and the data has the given member name or not + */ + public boolean isTooltipEnabledAndHasOrNullWarning(String memberName) { + return isTooltipEnabled() && hasOrNullWarning(memberName); + } + + /** + * Downloads the data if it is enabled. + * + * @param futureList the list to add the future to + */ + public void downloadIfEnabled(List> futureList) { + if (isDataEnabled()) { + download(futureList); + } + } + + /** + * Downloads the data. + * + * @param futureList the list to add the future to + */ + public void download(List> futureList) { + futureList.add(CompletableFuture.runAsync(this)); + } + + /** + * Downloads the data. + */ + @Override + public void run() { + try { + if (this.cacheable) { + HttpHeaders headers = Http.sendHeadRequest(address); + long combinedHash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); + + switch (this) { + case NPC, MOTES, MUSEUM, COLOR: + if (this.hash == combinedHash) return; + else this.hash = combinedHash; + } + } + + setData(SkyblockerMod.GSON.fromJson(Http.sendGetRequest(address), JsonObject.class)); + } catch (Exception e) { + ItemTooltip.LOGGER.warn("[Skyblocker] Failed to download " + this + " prices!", e); + } + } +} From 54b67d826aa84c40c506b46649483d5f08737134 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:16:44 -0400 Subject: [PATCH 7/9] Update exotic tooltip --- .../java/de/hysky/skyblocker/config/SkyblockerConfig.java | 2 +- .../skyblocker/config/categories/GeneralCategory.java | 8 ++++---- .../de/hysky/skyblocker/mixin/HandledScreenMixin.java | 4 +++- .../skyblocker/skyblock/item/tooltip/TooltipInfoType.java | 2 +- src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 4959ca3b0e..150179950d 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -487,7 +487,7 @@ public static class ItemTooltip { public boolean enableMuseumDate = true; @SerialEntry - public boolean enableExoticCheck = true; + public boolean enableExoticTooltip = true; } public static class ItemInfoDisplay { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index 8ce00172f6..b6865edcb6 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -357,10 +357,10 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) .option(Option.createBuilder() - .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck")) - .binding(defaults.general.itemTooltip.enableExoticCheck, - () -> config.general.itemTooltip.enableExoticCheck, - newValue -> config.general.itemTooltip.enableExoticCheck = newValue) + .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip")) + .binding(defaults.general.itemTooltip.enableExoticTooltip, + () -> config.general.itemTooltip.enableExoticTooltip, + newValue -> config.general.itemTooltip.enableExoticTooltip = newValue) .controller(ConfigUtils::createBooleanController) .build()) .build()) diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java index d7e5e824ab..b25db7cf06 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java @@ -6,7 +6,9 @@ import de.hysky.skyblocker.skyblock.experiment.ExperimentSolver; import de.hysky.skyblocker.skyblock.experiment.SuperpairsSolver; import de.hysky.skyblocker.skyblock.experiment.UltrasequencerSolver; -import de.hysky.skyblocker.skyblock.item.*; +import de.hysky.skyblocker.skyblock.item.ItemProtection; +import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds; +import de.hysky.skyblocker.skyblock.item.WikiLookup; import de.hysky.skyblocker.skyblock.item.tooltip.BackpackPreview; import de.hysky.skyblocker.skyblock.item.tooltip.CompactorDeletorPreview; import de.hysky.skyblocker.utils.ItemUtils; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index ddc8bd1cef..b786f4c16f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -21,7 +21,7 @@ public enum TooltipInfoType implements Runnable { THREE_DAY_AVERAGE("https://moulberry.codes/auction_averages_lbin/3day.json", itemTooltip -> itemTooltip.enableAvgBIN, false), MOTES("https://hysky.de/api/motesprice", itemTooltip -> itemTooltip.enableMotesPrice, itemTooltip -> itemTooltip.enableMotesPrice && Utils.isInTheRift(), true), MUSEUM("https://hysky.de/api/museum", itemTooltip -> itemTooltip.enableMuseumDate, true), - COLOR("https://hysky.de/api/color", itemTooltip -> itemTooltip.enableExoticCheck, true); + COLOR("https://hysky.de/api/color", itemTooltip -> itemTooltip.enableExoticTooltip, true); private final String address; private final Predicate dataEnabled; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 2373468b76..b1aa7e4480 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -77,7 +77,7 @@ "text.autoconfig.skyblocker.option.general.itemTooltip.enableLowestBIN": "Enable Lowest BIN Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableBazaarPrice": "Enable Bazaar buy/sell Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMuseumDate": "Enable Museum & Date", - "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticCheck": "Enable Exotic Check", + "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip": "Enable Exotic Tooltip", "text.autoconfig.skyblocker.option.general.itemInfoDisplay": "Item Info Display", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo": "Attribute Shard Info", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo.@Tooltip": "Displays the attribute's level as the stack count and the initials of the attribute's name.", From 81c6d870e9806729eb20be5e2d6c5fbe05ab8a02 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:44:22 -0400 Subject: [PATCH 8/9] Update text --- .../de/hysky/skyblocker/config/categories/GeneralCategory.java | 1 + .../de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java | 1 + src/main/resources/assets/skyblocker/lang/en_us.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index b6865edcb6..3cbb1b94ff 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -358,6 +358,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip.@Tooltip"))) .binding(defaults.general.itemTooltip.enableExoticTooltip, () -> config.general.itemTooltip.enableExoticTooltip, newValue -> config.general.itemTooltip.enableExoticTooltip = newValue) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java index 55a91392aa..66d94890cc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ExoticTooltip.java @@ -78,6 +78,7 @@ public enum DyeType implements StringIdentifiable { EXOTIC("exotic", Formatting.GOLD); private final String name; private final Formatting formatting; + DyeType(String name, Formatting formatting) { this.name = name; this.formatting = formatting; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b1aa7e4480..c0f3c7bace 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -78,6 +78,7 @@ "text.autoconfig.skyblocker.option.general.itemTooltip.enableBazaarPrice": "Enable Bazaar buy/sell Price", "text.autoconfig.skyblocker.option.general.itemTooltip.enableMuseumDate": "Enable Museum & Date", "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip": "Enable Exotic Tooltip", + "text.autoconfig.skyblocker.option.general.itemTooltip.enableExoticTooltip.@Tooltip": "Displays the type of exotic below the item's name if an armor piece is exotic.", "text.autoconfig.skyblocker.option.general.itemInfoDisplay": "Item Info Display", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo": "Attribute Shard Info", "text.autoconfig.skyblocker.option.general.itemInfoDisplay.attributeShardInfo.@Tooltip": "Displays the attribute's level as the stack count and the initials of the attribute's name.", From b944188297014cf0bbd5ebcb4c124b2ca77a5cee Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:56:50 -0400 Subject: [PATCH 9/9] Refactor TooltipInfoType#run --- .../item/tooltip/TooltipInfoType.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index b786f4c16f..086fcb0070 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -82,10 +82,6 @@ public JsonObject getData() { return data; } - public void setData(JsonObject data) { - this.data = data; - } - /** * Checks if the data has the given member name and sends a warning message if data is null. * @@ -135,18 +131,13 @@ public void download(List> futureList) { @Override public void run() { try { - if (this.cacheable) { + if (cacheable) { HttpHeaders headers = Http.sendHeadRequest(address); - long combinedHash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); - - switch (this) { - case NPC, MOTES, MUSEUM, COLOR: - if (this.hash == combinedHash) return; - else this.hash = combinedHash; - } + long hash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); + if (this.hash == hash) return; + else this.hash = hash; } - - setData(SkyblockerMod.GSON.fromJson(Http.sendGetRequest(address), JsonObject.class)); + data = SkyblockerMod.GSON.fromJson(Http.sendGetRequest(address), JsonObject.class); } catch (Exception e) { ItemTooltip.LOGGER.warn("[Skyblocker] Failed to download " + this + " prices!", e); }