diff options
Diffstat (limited to 'src/main/java')
8 files changed, 158 insertions, 91 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java index 22d360e5..e68c54c8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ChatListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -212,11 +212,8 @@ public class ChatListener { SBInfo.getInstance().setCurrentProfile(unformatted .substring("Your profile was changed to: ".length()) .split(" ")[0].trim()); - } else if (unformatted.startsWith("Player List Info is now disabled!")) { - SBInfo.getInstance().hasNewTab = false; - } else if (unformatted.startsWith("Player List Info is now enabled!")) { - SBInfo.getInstance().hasNewTab = true; } + if (e.message.getFormattedText().equals( EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED + "You haven't unlocked this recipe!" + EnumChatFormatting.RESET)) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java index c97ddbea..62f291c0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -21,10 +21,10 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.miscfeatures.tablisttutorial.TablistAPI; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.util.ItemUtils; -import io.github.moulberry.notenoughupdates.util.TabListUtils; import net.minecraft.client.Minecraft; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; @@ -95,8 +95,8 @@ public class MinionHelperInventoryLoader { private void checkLocalPelts() { int pelts = -1; - for (String name : TabListUtils.getTabList()) { - Matcher matcher = PATTERN_PELTS.matcher(name); + for (String line : TablistAPI.getOptionalWidgetLines(TablistAPI.WidgetNames.TRAPPER)) { + Matcher matcher = PATTERN_PELTS.matcher(line); if (matcher.matches()) { pelts = Integer.parseInt(matcher.group(1)); break; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorBooleanState.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorBooleanState.java new file mode 100644 index 00000000..a2102487 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorBooleanState.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.client.renderer.GlStateManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(GlStateManager.BooleanState.class) +public interface AccessorBooleanState { + @Accessor("currentState") + boolean getCurrentState(); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGlStateManager.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGlStateManager.java new file mode 100644 index 00000000..2b543c00 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorGlStateManager.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.client.renderer.GlStateManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(GlStateManager.class) +public interface AccessorGlStateManager { + @Accessor("lightingState") + static GlStateManager.BooleanState getLightingState() {throw new AssertionError();} +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java index 3bfb2f47..0d94cd1b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -390,6 +390,9 @@ public class EquipmentOverlay { ItemStack heldItem = Minecraft.getMinecraft().thePlayer.getHeldItem(); List<String> heldItemLore = ItemUtils.getLore(heldItem); + if (heldItemLore.isEmpty()) { + return; + } String itemType = Objects.requireNonNull(StringUtils.substringAfterLast(heldItemLore.get(heldItemLore.size() - 1), " "), "null"); if (!Arrays.asList("NECKLACE", "CLOAK", "BELT", "GLOVES", "BRACELET").contains(itemType)) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index f8019b85..f2d2886d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -26,11 +26,11 @@ import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; import io.github.moulberry.notenoughupdates.guifeatures.SkyMallDisplay; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; +import io.github.moulberry.notenoughupdates.miscfeatures.tablisttutorial.TablistAPI; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.StarCultCalculator; -import io.github.moulberry.notenoughupdates.util.TabListUtils; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; @@ -51,13 +51,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static io.github.moulberry.notenoughupdates.util.Utils.showOutdatedRepoNotification; -import static net.minecraft.util.EnumChatFormatting.BLUE; -import static net.minecraft.util.EnumChatFormatting.BOLD; import static net.minecraft.util.EnumChatFormatting.DARK_AQUA; import static net.minecraft.util.EnumChatFormatting.GOLD; import static net.minecraft.util.EnumChatFormatting.GREEN; import static net.minecraft.util.EnumChatFormatting.RED; -import static net.minecraft.util.EnumChatFormatting.RESET; import static net.minecraft.util.EnumChatFormatting.YELLOW; public class MiningOverlay extends TextTabOverlay { @@ -239,7 +236,7 @@ public class MiningOverlay extends TextTabOverlay { @Override public void update() { - overlayStrings = null; + overlayStrings = new ArrayList<>(); NEUConfig.HiddenProfileSpecific profileConfig = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay && @@ -257,43 +254,31 @@ public class MiningOverlay extends TextTabOverlay { commissionProgress.clear(); // These strings will be displayed one after the other when the player list is disabled - String mithrilPowder = RED + "[NEU] Failed to get data from your tablist"; - String gemstonePowder = RED + "Please enable player list info in your SkyBlock settings"; + String mithrilPowder = ""; + String gemstonePowder = ""; int forgeInt = 0; - boolean commissions = false; - boolean forges = false; - for (String name : TabListUtils.getTabList()) { - if (name.contains("Mithril Powder:")) { - mithrilPowder = DARK_AQUA + Utils.trimWhitespaceAndFormatCodes(name).replaceAll("\u00a7[f|F|r]", ""); - continue; - } + List<String> powderLines = getTabLinesOrAddWarning(1, TablistAPI.WidgetNames.POWDER); + getTabLinesOrAddWarning(2, TablistAPI.WidgetNames.POWDER); - if (name.contains("Gemstone Powder:")) { - gemstonePowder = DARK_AQUA + Utils.trimWhitespaceAndFormatCodes(name).replaceAll("\u00a7[f|F|r]", ""); - continue; + for (String line : powderLines) { + if (line.contains("Mithril:")) { + mithrilPowder = DARK_AQUA + Utils.trimWhitespaceAndFormatCodes(line).replaceAll("\u00a7[f|F|r]", ""); } - - Matcher forgesMatcher = forgesHeaderPattern.matcher(name); - if (forgesMatcher.matches() && profileConfig != null) { - commissions = false; - forges = true; - continue; + if (line.contains("Gemstone:")) { + gemstonePowder = DARK_AQUA + Utils.trimWhitespaceAndFormatCodes(line).replaceAll("\u00a7[f|F|r]", ""); } + } - // Commissions appear after Forges, start enumerating Commissions instead of Forges - if (name.equals(RESET.toString() + BLUE + BOLD + "Commissions" + RESET) && profileConfig != null) { - commissions = true; - forges = false; - continue; - } + List<String> tabForgeLines = getTabLinesOrAddWarning(3, TablistAPI.WidgetNames.FORGE); + for (String name : tabForgeLines) { String cleanName = StringUtils.cleanColour(name); - if (forges && cleanName.startsWith(" ") && profileConfig != null) { + if (cleanName.startsWith(" ") && profileConfig != null) { char firstChar = cleanName.trim().charAt(0); if (firstChar < '0' || firstChar > '9') { - forges = false; + break; } else { if (name.contains("LOCKED")) { @@ -344,7 +329,13 @@ public class MiningOverlay extends TextTabOverlay { } forgeInt++; } - } else if (commissions && cleanName.startsWith(" ") && profileConfig != null) { + } + } + List<String> tabCommissionLines = getTabLinesOrAddWarning(0, TablistAPI.WidgetNames.COMMISSIONS); + + for (String name : tabCommissionLines) { + String cleanName = StringUtils.cleanColour(name); + if (cleanName.startsWith(" ") && profileConfig != null) { String[] split = cleanName.trim().split(": "); if (split.length == 2) { if (split[1].endsWith("%")) { @@ -358,16 +349,9 @@ public class MiningOverlay extends TextTabOverlay { commissionProgress.put(split[0], 1.0f); } } - } else { - commissions = false; - forges = false; } } - if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) { - return; - } - List<String> commissionsStrings = new ArrayList<>(); for (Map.Entry<String, Float> entry : commissionProgress.entrySet()) { if (entry.getValue() >= 1) { @@ -421,7 +405,6 @@ public class MiningOverlay extends TextTabOverlay { DARK_AQUA + "Pickaxe CD: \u00a7a" + (ItemCooldowns.pickaxeUseCooldownMillisRemaining / 1000) + "s"; } - overlayStrings = new ArrayList<>(); for (int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) { switch (index) { case 0: @@ -523,6 +506,22 @@ public class MiningOverlay extends TextTabOverlay { if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null; } + private List<String> getTabLinesOrAddWarning(int configIndex, TablistAPI.WidgetNames widgetName) { + List<String> lines; + if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.contains(configIndex) && + NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) { + lines = TablistAPI.getWidgetLinesWithoutNotification(widgetName); + if (lines.isEmpty() && !overlayStrings.contains("§l§4One or more tab widgets missing!")) { + overlayStrings.add("§l§4One or more tab widgets missing!"); + overlayStrings.add("§l§4Enable it in §b/tab§4!"); + } + } else { + lines = TablistAPI.getOptionalWidgetLines(widgetName); + } + + return lines; + } + private String getTipPart(String name) { int settings = NotEnoughUpdates.INSTANCE.config.mining.commissionTaskTips; if (settings == 0) return ""; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java index 3d7f6d40..eb6a5696 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -39,6 +39,7 @@ import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; @@ -139,12 +140,12 @@ public class ItemUtils { is.setTagCompound(tagCompound); } - public static List<String> getLore(ItemStack is) { + public static @NotNull List<@NotNull String> getLore(@Nullable ItemStack is) { if (is == null) return new ArrayList<>(); return getLore(is.getTagCompound()); } - public static List<String> getLore(NBTTagCompound tagCompound) { + public static @NotNull List<@NotNull String> getLore(@Nullable NBTTagCompound tagCompound) { if (tagCompound == null) { return Collections.emptyList(); } @@ -156,7 +157,13 @@ public class ItemUtils { return list; } - public static String getDisplayName(NBTTagCompound compound) { + public static @Nullable String getDisplayName(@Nullable ItemStack itemStack) { + if (itemStack == null) + return null; + return getDisplayName(itemStack.getTagCompound()); + } + + public static @Nullable String getDisplayName(@Nullable NBTTagCompound compound) { if (compound == null) return null; String string = compound.getCompoundTag("display").getString("Name"); if (string == null || string.isEmpty()) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index ad2a0542..86799147 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -27,12 +27,12 @@ import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.events.SidebarChangeEvent; import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; +import io.github.moulberry.notenoughupdates.miscfeatures.tablisttutorial.TablistAPI; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.init.Blocks; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.Slot; @@ -108,7 +108,6 @@ public class SBInfo { public long unloadedWorld = -1; private JsonObject locraw = null; public boolean isInDungeon = false; - public boolean hasNewTab = false; public enum Gamemode { NORMAL("", ""), IRONMAN("Ironman", "♲"), STRANDED("Stranded", "☀"); @@ -242,7 +241,6 @@ public class SBInfo { joinedWorld = System.currentTimeMillis(); currentlyOpenChestName = ""; lastOpenChestName = ""; - hasNewTab = false; } @SubscribeEvent @@ -307,7 +305,6 @@ public class SBInfo { return lastLocation; } - private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a"; private static final String completedFactionQuests = "\u00a7r \u00a7r\u00a7a(?!(Paul|Finnegan|Aatrox|Cole|Diana|Diaz|Foxy|Marina)).*"; @@ -332,40 +329,40 @@ public class SBInfo { updateMayor(); lastMayorUpdate = currentTime; } - try { - for (NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); - if (name.startsWith(profilePrefix)) { - String newProfile = Utils.cleanColour(name.substring(profilePrefix.length())); - setCurrentProfile(newProfile); - if (!Objects.equals(currentProfile, newProfile)) { - currentProfile = newProfile; - if (NotEnoughUpdates.INSTANCE.config != null) - if (NotEnoughUpdates.INSTANCE.config.mining.powderGrindingTrackerResetMode == 2) - OverlayManager.powderGrindingOverlay.load(); - } - hasNewTab = true; - } else if (name.startsWith(skillsPrefix)) { - String levelInfo = name.substring(skillsPrefix.length()).trim(); - Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]); - if (matcher.find()) { - try { - int level = Integer.parseInt(matcher.group(2).trim()); - XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level); - } catch (Exception ignored) { - } - } - } else if (name.matches(completedFactionQuests) && "crimson_isle".equals(mode)) { - if (completedQuests.isEmpty()) { - completedQuests.add(name); - } else if (!completedQuests.contains(name)) { - completedQuests.add(name); - } + List<String> profileData = TablistAPI.getWidgetLines(TablistAPI.WidgetNames.PROFILE); + if (!profileData.isEmpty()) { + String newProfile = Utils.cleanColour(profileData.get(0)).split(" ")[1]; + if (Character.isLowerCase(newProfile.charAt(0))) + newProfile = new StringBuilder(newProfile).reverse().toString(); + setCurrentProfile(newProfile); + } + // todo convert to api + for (String s : TabListUtils.getTabList()) { + if (s.matches(completedFactionQuests) && "crimson_isle".equals(mode)) { + if (completedQuests.isEmpty()) { + completedQuests.add(s); + } else if (!completedQuests.contains(s)) { + completedQuests.add(s); } } - } catch (Exception e) { - e.printStackTrace(); +// else if (s.startsWith(skillsPrefix)) { +// String levelInfo = s.substring(skillsPrefix.length()).trim(); +// Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]); +// if (matcher.find()) { +// try { +// int level = Integer.parseInt(matcher.group(2).trim()); +// XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level); +// } catch (Exception ignored) { +// } +// } +// } } +// for (String line : TablistAPI.getWidgetLines(new TablistTutorial.TabListWidget( +// "ALL", +// TablistAPI.WidgetNames.SKILLS +// ))) { +// +// } try { List<String> lines = SidebarUtil.readSidebarLines(true, false); @@ -481,6 +478,9 @@ public class SBInfo { currentProfile = newProfile; MinionHelperManager.getInstance().onProfileSwitch(); CookieWarning.onProfileSwitch(); + if (NotEnoughUpdates.INSTANCE.config != null) + if (NotEnoughUpdates.INSTANCE.config.mining.powderGrindingTrackerResetMode == 2) + OverlayManager.powderGrindingOverlay.load(); } } } |