diff --git a/CHANGELOG.md b/CHANGELOG.md index 9223c36ab..9ede6e31d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,50 +1,51 @@ -## [1.15.1-beta.3](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.2...v1.15.1-beta.3) (2023-05-16) +## [1.15.1-beta.7](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.6...v1.15.1-beta.7) (2023-09-13) -### New Features +### Bug Fixes -* Add K and M to convertEmeraldPrice ([#661](https://github.com/Wynntils/Wynntils/issues/661)) ([8a295f0](https://github.com/Wynntils/Wynntils/commit/8a295f0e5e67f2b66305fa730d2db8a6b274fde9)) +* Fix Guild Map Crashing ([#689](https://github.com/Wynntils/Wynntils/issues/689)) ([e5cc971](https://github.com/Wynntils/Wynntils/commit/e5cc9718dad93581000783c1a298862e6da91c99)) -## [1.15.1-beta.2](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.1...v1.15.1-beta.2) (2023-04-17) +## [1.15.1-beta.6](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.5...v1.15.1-beta.6) (2023-08-12) ### Bug Fixes -* The mod can now load Artemis (1.19.3) lootruns ([#675](https://github.com/Wynntils/Wynntils/issues/675)) ([cc98eb1](https://github.com/Wynntils/Wynntils/commit/cc98eb12022bf752acdd359883a9254ae35d192c)) +* Fixed TAB_EFFECT_PATTERN regex ([#686](https://github.com/Wynntils/Wynntils/issues/686)) ([46408de](https://github.com/Wynntils/Wynntils/commit/46408de7d589c2dc5ef6dcabe54eb4bfe27d39bf)) ### Miscellaneous Chores -* **release:** v1.15.1-beta.2 [skip ci] ([28538a3](https://github.com/Wynntils/Wynntils/commit/28538a36d44442a94940193c981a00604b4fa9d0)) +* **release:** v1.15.1-beta.6 [skip ci] ([71bf7fe](https://github.com/Wynntils/Wynntils/commit/71bf7fee9698345af1b61eb7f3b39c57b51fb497)) -## [1.15.1-beta.1](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.0...v1.15.1-beta.1) (2023-04-01) +## [1.15.1-beta.5](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.4...v1.15.1-beta.5) (2023-07-24) ### New Features -* Add Artemis export button for waypoint manager GUI ([#673](https://github.com/Wynntils/Wynntils/issues/673)) ([1ea89ce](https://github.com/Wynntils/Wynntils/commit/1ea89ce88cb334233387bc971c9218cd5c1d5ee1)) +* Export favorites via command ([#681](https://github.com/Wynntils/Wynntils/issues/681)) ([103a8b8](https://github.com/Wynntils/Wynntils/commit/103a8b8614f27e8381c01599ca9d35ad68451193)) ### Miscellaneous Chores -* **release:** v1.15.1-beta.1 [skip ci] ([bf060a2](https://github.com/Wynntils/Wynntils/commit/bf060a250ebddac1a4139d5ae312a96316bafe0a)) +* **release:** v1.15.1-beta.5 [skip ci] ([1677480](https://github.com/Wynntils/Wynntils/commit/1677480cf1d047e1e131f11a5b9f56a052a110d9)) -## [1.15.1-beta.0](https://github.com/Wynntils/Wynntils/compare/v1.15.0...v1.15.1-beta.0) (2023-04-01) +## [1.15.1-beta.4](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.3...v1.15.1-beta.4) (2023-07-18) -### Bug Fixes +### Miscellaneous Chores -* Fix party finder crash on housing island ([#669](https://github.com/Wynntils/Wynntils/issues/669)) ([f97f5ad](https://github.com/Wynntils/Wynntils/commit/f97f5ad803fba62e3a38c31b74e027c0214ed41d)) +* **release:** v1.15.1-beta.4 [skip ci] ([b0e0d5b](https://github.com/Wynntils/Wynntils/commit/b0e0d5b34ce26d519a26c8cef32b3be8c645bd88)) +* Remove broken quest book ([#679](https://github.com/Wynntils/Wynntils/issues/679)) ([b9d15f5](https://github.com/Wynntils/Wynntils/commit/b9d15f51efbecfead2afaf9cbac4569ecbf651bb)) +## [1.15.1-beta.3](https://github.com/Wynntils/Wynntils/compare/v1.15.1-beta.2...v1.15.1-beta.3) (2023-05-16) -### Miscellaneous Chores -* **release:** v1.15.1-beta.0 [skip ci] ([d60803c](https://github.com/Wynntils/Wynntils/commit/d60803cf7ac832394fc9c981217b2331ccf51821)) +### New Features -## [1.15.0](https://github.com/Wynntils/Wynntils/compare/v1.14.1-beta.14...v1.15.0) (2023-02-21) +* Add K and M to convertEmeraldPrice ([#661](https://github.com/Wynntils/Wynntils/issues/661)) ([8a295f0](https://github.com/Wynntils/Wynntils/commit/8a295f0e5e67f2b66305fa730d2db8a6b274fde9)) ### Miscellaneous Chores -* **release:** v1.15.0 [skip ci] ([1a93a1e](https://github.com/Wynntils/Wynntils/commit/1a93a1eb9decc0acf497c7f923a3032c00c5e65b)) +* **release:** v1.15.1-beta.3 [skip ci] ([ffab244](https://github.com/Wynntils/Wynntils/commit/ffab244e16a0ab9c3613b11f732ae0e1d2be7719)) diff --git a/src/main/java/com/wynntils/core/framework/instances/data/TabListData.java b/src/main/java/com/wynntils/core/framework/instances/data/TabListData.java index 19f0c2309..241670f1f 100644 --- a/src/main/java/com/wynntils/core/framework/instances/data/TabListData.java +++ b/src/main/java/com/wynntils/core/framework/instances/data/TabListData.java @@ -26,7 +26,7 @@ CG3 is the duration string (eg. "1:23") https://regexr.com/729qc */ - private static final Pattern TAB_EFFECT_PATTERN = Pattern.compile("(.+?§7 ?(?:\\d+(?:\\.\\d+)?%)?) ?([%\\-+\\/\\da-zA-Z\\s]+?) §[84a]\\((.+?)\\).*"); + private static final Pattern TAB_EFFECT_PATTERN = Pattern.compile("(.+?§7 ?(?:\\d+(?:\\.\\d+)?%)?) ?(['%\\-+\\/\\da-zA-Z\\s]+?) §[84a]\\((.+?)\\).*"); /** * Updates the ConsumableTimerOverlay with the effects from the tab list diff --git a/src/main/java/com/wynntils/modules/map/overlays/objects/MapTerritory.java b/src/main/java/com/wynntils/modules/map/overlays/objects/MapTerritory.java index 19b121a48..408473283 100644 --- a/src/main/java/com/wynntils/modules/map/overlays/objects/MapTerritory.java +++ b/src/main/java/com/wynntils/modules/map/overlays/objects/MapTerritory.java @@ -10,22 +10,26 @@ import com.wynntils.core.framework.rendering.colors.CommonColors; import com.wynntils.core.framework.rendering.colors.CustomColor; import com.wynntils.core.framework.rendering.textures.Textures; -import com.wynntils.core.utils.StringUtils; import com.wynntils.core.utils.objects.Storage; import com.wynntils.modules.map.configs.MapConfig; import com.wynntils.modules.map.instances.GuildResourceContainer; import com.wynntils.modules.map.instances.MapProfile; import com.wynntils.modules.map.managers.GuildResourceManager; import com.wynntils.modules.map.overlays.renderer.MapInfoUI; +import com.wynntils.webapi.WebManager; import com.wynntils.webapi.profiles.TerritoryProfile; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.text.TextFormatting; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Random; public class MapTerritory { private static final CustomColor territoryNameColour = new CustomColor(CommonColors.WHITE); + private static final HashMap backupGuildColors = new HashMap<>(); ScreenRenderer renderer = null; @@ -64,7 +68,7 @@ public MapTerritory(TerritoryProfile territory) { description.add(TextFormatting.GRAY + "✦ Treasury: " + resources.getTreasury()); description.add(TextFormatting.GRAY + "Territory Defences: " + resources.getDefences()); description.add(""); - + String treasuryColor = resources.getTreasury().substring(0, 2); description.add(TextFormatting.GRAY + "Time held: " + treasuryColor + territory.getReadableRelativeTimeAcquired()); @@ -160,12 +164,26 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks, boolean terri } private CustomColor getTerritoryColor(boolean resourceColor) { - if (!resourceColor) { - return territory.getGuildColor() == null ? StringUtils.colorFromString(territory.getGuild()) : - StringUtils.colorFromHex(territory.getGuildColor()); - } else { - return resources.getColor(); + if (resourceColor) return resources.getColor(); + + if (WebManager.getGuildColors().containsKey(territory.getGuild())) { + return WebManager.getGuildColors().get(territory.getGuild()); + } + + // Guild not found in the list, check backup list and add a random color if not found + if (!backupGuildColors.containsKey(territory.getGuild())) { + Random random = new Random(); + backupGuildColors.put( + territory.getGuild(), + CustomColor.fromHSV( + random.nextFloat(), + random.nextFloat(), + 0.5f + random.nextFloat() * 0.5f, + 1f + ) + ); } + return backupGuildColors.get(territory.getGuild()); } public void postDraw(int mouseX, int mouseY, float partialTicks, int width, int height) { diff --git a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java index 9e0867ebf..e9b134c3d 100644 --- a/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java +++ b/src/main/java/com/wynntils/modules/questbook/QuestBookModule.java @@ -8,11 +8,11 @@ import com.wynntils.core.framework.instances.Module; import com.wynntils.core.framework.interfaces.annotations.ModuleInfo; import com.wynntils.modules.questbook.commands.CommandExportDiscoveries; +import com.wynntils.modules.questbook.commands.CommandExportFavorites; import com.wynntils.modules.questbook.configs.QuestBookConfig; import com.wynntils.modules.questbook.enums.Guides; import com.wynntils.modules.questbook.enums.QuestBookPages; import com.wynntils.modules.questbook.events.ClientEvents; -import com.wynntils.modules.questbook.managers.QuestManager; import com.wynntils.modules.questbook.overlays.hud.TrackedQuestOverlay; import net.minecraftforge.client.settings.KeyConflictContext; import org.lwjgl.input.Keyboard; @@ -31,6 +31,7 @@ public void onEnable() { registerOverlay(new TrackedQuestOverlay(), Priority.HIGHEST); registerCommand(new CommandExportDiscoveries()); + registerCommand(new CommandExportFavorites()); registerKeyBinding("Open Quest Book", Keyboard.KEY_K, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.QUESTS.getPage().open(true)); registerKeyBinding("Open Discoveries", Keyboard.KEY_U, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.DISCOVERIES.getPage().open(true)); @@ -39,7 +40,7 @@ public void onEnable() { registerKeyBinding("Open HUD configuration", Keyboard.KEY_NONE, "Wynntils", KeyConflictContext.IN_GAME, true, () -> QuestBookPages.HUDCONFIG.getPage().open(true)); registerKeyBinding("Open Menu", Keyboard.KEY_I, "Wynntils", KeyConflictContext.IN_GAME, true, () -> { QuestBookPages.MAIN.getPage().open(true); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); }); } diff --git a/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java new file mode 100644 index 000000000..79670cfc1 --- /dev/null +++ b/src/main/java/com/wynntils/modules/questbook/commands/CommandExportFavorites.java @@ -0,0 +1,60 @@ +/* + * * Copyright © Wynntils - 2022. + */ + +package com.wynntils.modules.questbook.commands; + +import com.wynntils.McIf; +import com.wynntils.core.utils.Utils; +import com.wynntils.modules.utilities.configs.UtilitiesConfig; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraftforge.client.IClientCommand; + +import java.util.ArrayList; +import java.util.List; + +public class CommandExportFavorites extends CommandBase implements IClientCommand { + + + @Override + public String getName() { + return "exportfavorites"; + } + + @Override + public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) { + return false; + } + + @Override + public String getUsage(ICommandSender sender) { + return "exportfavorites"; + } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + ITextComponent command = new TextComponentString("/exportfavorites"); + command.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/exportfavorites")); + + List combinedList = new ArrayList<>(); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteItems); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteIngredients); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoritePowders); + combinedList.addAll(UtilitiesConfig.INSTANCE.favoriteEmeraldPouches); + + Utils.copyToClipboard("wynntilsFavorites," + String.join(",", combinedList)); + McIf.player().sendMessage(new TextComponentString(TextFormatting.GREEN + "Copied favorites to clipboard! Open the guide list and click the + button on Artemis to import them.")); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +} diff --git a/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java b/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java index 203c489b3..716e0c567 100644 --- a/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java +++ b/src/main/java/com/wynntils/modules/questbook/events/ClientEvents.java @@ -146,7 +146,7 @@ public void updateQuestBook(TickEvent.ClientTickEvent e) { QuestBookPages.MAIN.getPage().open(true); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); } private int tickCounter = 0; diff --git a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java index 19c63d8da..fe8dd1c63 100644 --- a/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java +++ b/src/main/java/com/wynntils/modules/questbook/instances/QuestBookListPage.java @@ -8,10 +8,14 @@ import com.wynntils.core.framework.rendering.ScreenRenderer; import com.wynntils.core.framework.rendering.SmartFontRenderer; import com.wynntils.core.framework.rendering.colors.CommonColors; +import com.wynntils.modules.questbook.overlays.ui.DialoguePage; +import com.wynntils.modules.questbook.overlays.ui.DiscoveriesPage; +import com.wynntils.modules.questbook.overlays.ui.QuestsPage; import net.minecraft.client.gui.ScaledResolution; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -49,49 +53,54 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { { preEntries(mouseX, mouseY, partialTicks); - // Page Text - render.drawString(currentPage + " / " + pages, x + 80, y + 88, CommonColors.BLACK, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); + if (this instanceof QuestsPage || this instanceof DiscoveriesPage || this instanceof DialoguePage) { + // Page Text + render.drawString(currentPage + " / " + pages, x + 80, y + 88, CommonColors.BLACK, SmartFontRenderer.TextAlignment.MIDDLE, SmartFontRenderer.TextShadow.NONE); + List textLines = Arrays.asList("The Wynntils quest book is", "no longer available on 1.12.2.", "", "Wynntils 1.12.2 is being", "sunset in favour of newer", "Minecraft versions.", "", "Please download the latest", "version of the mod at", "https://wynntils.com"); + drawTextLines(textLines, x + 10, y - 40, 1); - //Forward and backward button - drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); - - // Draw all Search Results - if (search.size() > 0) { - List page = search.get(currentPage - 1); - - if (page.size() > 0) { - for (int i = 0; i < page.size(); i++) { - T currentItem = page.get(i); - - if (isHovered(i, posX, posY) && !showAnimation) { - //hovered - drawEntry(currentItem, i, true); - - selectedEntry = currentItem; - //selected is set relative to the page - selected = i; - hoveredText = getHoveredText(selectedEntry); - } else { - if (selected == i) { - selectedEntry = null; + } else { + //Forward and backward button + drawForwardAndBackButtons(x, y, posX, posY, currentPage, pages); + + // Draw all Search Results + if (search.size() > 0) { + List page = search.get(currentPage - 1); + + if (page.size() > 0) { + for (int i = 0; i < page.size(); i++) { + T currentItem = page.get(i); + + if (isHovered(i, posX, posY) && !showAnimation) { + //hovered + drawEntry(currentItem, i, true); + + selectedEntry = currentItem; + //selected is set relative to the page + selected = i; + hoveredText = getHoveredText(selectedEntry); + } else { + if (selected == i) { + selectedEntry = null; + } + + //not hovered + drawEntry(currentItem, i, false); } - - //not hovered - drawEntry(currentItem, i, false); } } - } - } else { - String textToDisplay = getEmptySearchString(); - int currentY = 12; + } else { + String textToDisplay = getEmptySearchString(); + int currentY = 12; - for (String line : textToDisplay.split("\n")) { - currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; - } + for (String line : textToDisplay.split("\n")) { + currentY += render.drawSplitString(line, 120, x + 26, y - 95 + currentY, 10, CommonColors.BLACK, SmartFontRenderer.TextAlignment.LEFT_RIGHT, SmartFontRenderer.TextShadow.NONE) * 10 + 2; + } - updateSearch(); + updateSearch(); + } + postEntries(mouseX, mouseY, partialTicks); } - postEntries(mouseX, mouseY, partialTicks); } ScreenRenderer.endGL(); renderHoveredText(mouseX, mouseY); diff --git a/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java b/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java index 276d8d393..4f0bded08 100644 --- a/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java +++ b/src/main/java/com/wynntils/modules/questbook/managers/QuestManager.java @@ -68,7 +68,7 @@ public static void updateAnalysis(Collection position, boolean } if (immediate) { - readQuestBook(); + //readQuestBook(); } } diff --git a/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java b/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java index 08fd12675..3ff409e06 100644 --- a/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java +++ b/src/main/java/com/wynntils/modules/questbook/overlays/ui/QuestsPage.java @@ -56,7 +56,7 @@ public List getHoveredDescription() { public void open(boolean showAnimation) { super.open(showAnimation); - QuestManager.readQuestBook(); + //QuestManager.readQuestBook(); } @Override diff --git a/src/main/java/com/wynntils/webapi/WebManager.java b/src/main/java/com/wynntils/webapi/WebManager.java index 99092eca5..60bac9f02 100644 --- a/src/main/java/com/wynntils/webapi/WebManager.java +++ b/src/main/java/com/wynntils/webapi/WebManager.java @@ -15,6 +15,7 @@ import com.wynntils.Reference; import com.wynntils.core.events.custom.WynnGuildWarEvent; import com.wynntils.core.framework.FrameworkManager; +import com.wynntils.core.framework.rendering.colors.CustomColor; import com.wynntils.core.utils.Utils; import com.wynntils.modules.core.enums.UpdateStream; import com.wynntils.modules.core.overlays.UpdateOverlay; @@ -37,7 +38,6 @@ import com.wynntils.webapi.profiles.item.ItemGuessProfile; import com.wynntils.webapi.profiles.item.ItemProfile; import com.wynntils.webapi.profiles.item.enums.ItemType; -import com.wynntils.webapi.profiles.item.objects.IdentificationContainer; import com.wynntils.webapi.profiles.item.objects.MajorIdentification; import com.wynntils.webapi.profiles.music.MusicLocationsProfile; import com.wynntils.webapi.profiles.player.PlayerStatsProfile; @@ -68,6 +68,7 @@ public class WebManager { private static @Nullable WebReader apiUrls; private static HashMap territories = new HashMap<>(); + private static HashMap guildColors = new HashMap<>(); private static UpdateProfile updateProfile; private static boolean ignoringJoinUpdate = false; @@ -139,6 +140,7 @@ public static void setupWebApi(boolean withProgress) { } updateTerritories(handler); + updateGuildColors(handler); updateItemList(handler); updateIngredientList(handler); updateMapLocations(handler); @@ -207,6 +209,10 @@ public static HashMap getTerritories() { return territories; } + public static HashMap getGuildColors() { + return guildColors; + } + public static HashMap getItems() { return items; } @@ -331,6 +337,33 @@ public static void updateTerritories(RequestHandler handler) { ); } + public static void updateGuildColors(RequestHandler handler) { + if (apiUrls == null) return; + String url = apiUrls.get("Athena") + "/cache/get/guildListWithColors"; + handler.addRequest(new Request(url, "guildColors") + .cacheTo(new File(API_CACHE_ROOT, "guildColors.json")) + .handleJsonObject(json -> { + if (!json.has("0")) return false; + // json is {"0": {data}}, {"1": {data}}, etc. + // we need to convert it to {data}, {data}, etc. + guildColors = new HashMap<>(); + for (Map.Entry entry : json.entrySet()) { + JsonObject data = entry.getValue().getAsJsonObject(); + // data is now {"_id":"Kingdom Foxes","prefix":"Fox","color":"#FF8200"} + + String colorString = entry.getValue().getAsJsonObject().get("color").getAsString(); + if (colorString.length() != 7 && colorString.length() != 4 && colorString.length() != 3) continue; + + guildColors.put( // name, CustomColor + entry.getValue().getAsJsonObject().get("_id").getAsString(), + CustomColor.fromString(colorString, 1f) + ); + } + return true; + }) + ); + } + public static void updateCurrentSplash() { if (apiUrls == null || apiUrls.getList("Splashes") == null) return;