diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..28d8209de82f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,30 @@ +# top-most EditorConfig file +root = true + +# All Files +[*] +# Unix-style newlines with a newline ending every file +end_of_line = lf +insert_final_newline = true + +# Indent styling +indent_size = 4 +indent_style = space + +# Comments styling to add space after comment start +ij_any_block_comment_add_space = true +ij_any_line_comment_add_space = true + +# Max line length +max_line_length = 120 + +# Java Files +[*.java] +# Java files should not use wildcard imports +ij_java_names_count_to_use_import_on_demand = 999 +ij_java_class_count_to_use_import_on_demand = 999 + +[*.kt] +# Kotlin files should not use wildcard imports +ij_kotlin_name_count_to_use_star_import = 999 +ij_kotlin_name_count_to_use_star_import_for_members = 999 diff --git a/CHANGELOG.md b/CHANGELOG.md index d9b4f08ddfa3..a3a69d04b6fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,10 +40,29 @@ + Show the in-game date of SkyBlock (like in Apec, but with mild delays). + Includes the SkyBlock year. + Added Quest Item Helper. - NetheriteMiner - + When you open the fetch item quest in the town board, it shows a clickable chat message that will grab the items needed from the sacks. + + When you open the fetch item quest in the town board, it shows a clickable chat message that will grab the items + needed from the sacks. + Added alerts when the player catches a Legendary Sea Creature. - Cad + Added Soulweaver Skull Hider to the Dungeon Object Hider. - nea + Hide the annoying soulweaver skulls that float around you if you have the soulweaver gloves equipped. ++ Added /shmouselock command to lock mouse rotation for farming. - Cad ++ Added **Dungeon party finder** QOL improvements - Cad + + Floor stack size. + + Mark Paid Carries red. + + Mark Low-Class levels orange. + + Mark groups you can't join dark red. + + Mark groups without your current classes green. ++ Added shortcuts for **Party commands** and smart **tab complete**. - CalMWolfs + + /pw -> party warp + + /pk -> party kick + + /pt -> party transfer + + /pp -> party promote + + /pko -> party kickoffline ++ Added working **Livid Finder** (should work 100% of the time). - hannibal2 + + Option to hide other/wrong/fake Livids (try this out and see if you really want this, it can be counter-productive + in some cases). ++ Added AFK time to Discord RPC. - NetheriteMiner ++ Option to highlight items that are full in the sack inventory. #### Events @@ -52,6 +71,9 @@ + Thanks Tobbbb for the coordinates! + Support for hiding basket waypoints once you have clicked on them. - hannibal2 + Option to show only the closest basket. - hannibal2 ++ Help with the 2023 Halloween visitor challenge (ephemeral dingsibumsi or something) - nea + + New Visitor Ping: Pings you when you are less than 10 seconds away from getting a new visitor. + + Accept Hotkey: Accept a visitor when you press this keybind while in the visitor GUI. ### Changes @@ -72,6 +94,23 @@ + Changed the Yaw/Pitch Display to not show scientific notations at very small numbers. - Obsidian + Added an option to the Advanced Player List to hide Crimson Isle faction icons. - hannibal2 + Added Enrichment to Estimated Item Value. - jani ++ Added Plhlegblast to the Rare Sea Creature Warning and Highlight. - hannibal2 ++ Disabling all Diana features if no Diana mayor is active, allowing to overwrite the Diana mayor check if the election + API check failed. - CalMWolfs ++ Hiding a bunch of garden GUIs in a bunch of garden inventories. - hannibal2 ++ More shwords support. - CalMWolfs + + Added the option to change between case-sensitive and case-insensitive. + + Allow the use of Ctrl + C to copy the current textbox. + + The effect of visual words is now visible while editing text. ++ Added Diamond/Gold essence to chat filter powder mining. - HiZe ++ Added fillet count and coins to Bronze/Silver Trophy Sack. - HiZe ++ Chest value is now default disabled in the dungeon, and added an option to enable it. - HiZe ++ Added support for lower case item IDs to the Hypixel command /viewrecipe. - walker ++ Added support for tab complete item IDs in the Hypixel command /viewrecipe. - hannibal2 + + Only items with recipes are tab completed. ++ Added option to set the size of highlighted motes orbs in rift and make them smaller by default. - cimbraien ++ Disabled clicks on SkyHanni GUIs while inside NEU's or Skytils profile viewer. - hannibal2 ++ Removed armor stand checks for Trevor Solver. This fixes or nerfs the feature to not highlight mobs behind blocks sometimes. - hannibal2 ### Bug Fixes @@ -100,6 +139,27 @@ + Fixed Abiphone ring message not getting filtered correctly. - hannibal2 + Fixed the bug that faction icons in Crimson Isle are always hidden in the tab list. - hannibal2 + Fixed SkyHanni GUI Edit Button not working inside storage even if neu storage is not disabled. - hannibal2 ++ Hide "click" texts with the Fishing Hook Display. - hannibal2 ++ Fixed Highlight Showcase Items not working in some areas. - Obsidian ++ Fixed the Blaze Slayer Damage Indicator not working and no longer causing FPS drops. - hannibal2 ++ Fixed clean end working in f5/m5. - hannibal2 ++ Fixed visitor drop statistics preview. - Obsidian ++ Fixed a bracket at the wrong spot in Discord RPC. - hannibal2 ++ Fixed fishing hook display triggering on wrong texts. - hannibal2 ++ Fixed crop milestone inventory showing wrong level as stack size when maxed out. - hannibal2 ++ Fixed various bugs with the /shwords GUI. - CalMWolfs ++ Bring back the command /shwords - CalMWolfs ++ It got deleted accidentally during code optimisations. ++ Highlight Commission Mobs: The "Golden Goblin Slayer" Commission should not trigger the "Goblin Slayer" Commission + anymore. - Thunderblade73 ++ Fixed potential crash with future neu version. - CalMWolfs ++ Added missing beep sound to rejoin SkyBlock after kick warning. - hannibal2 ++ Fixed Fire Veil particle hider not working. - cimbraien ++ Fixed a bug with the Trophy Sack Display reading number. - HiZe ++ Fixed Ghost Counter item stack detection. - HiZe ++ Fixed Farming Weight Display shows 0 weight wrongly sometimes. - Kaeso ++ Fixed damage indicator errors during Enderman Slayer. - hannibal2 ++ Fixed weird error messages in the Damage Indicator. - hannibal2 #### Config @@ -111,6 +171,13 @@ + Removed **Duplicate Hider**. + Hypixel now fixed the bug themselves and hides duplicate farming contests in the Jacob inventory. +#### Internal Changes + ++ Add Repo TODOs to regex patterns. - walker ++ Moved many patterns from function scope to members. - hannibal2 ++ Avoid hardcoded dispatcher. - walker ++ Created and used Entity.canBeSeen and LorenzVec.canBeSeen. - hannibal2 + ## Version 0.20 ### New Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 997a6c68d1e4..50fb6b668ecf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,9 +73,6 @@ You can write in the description of the pr the wording for the changelog as well - Don't forget to add `@FeatureToggle` to new standalone features (not options to that feature) in the config. - Do not use `e.printStackTrace()`, use `CopyErrorCommand.logError(e, "explanation for users")` instead. - Do not use `MinecraftForge.EVENT_BUS.post(event)`, use `event.postAndCatch()` instead. -- Do not use wildcards in imports (see the imgae below for setting this up in IntelliJ) -- ![image](https://github.com/hannibal002/SkyHanni/assets/24389977/84c3a640-b39a-407e-a73c-12e548f33e88) - ## Software Used in SkyHanni @@ -128,8 +125,8 @@ SkyHanni uses a repo system to easily change static variables without the need f The repo is located at https://github.com/hannibal002/SkyHanni-REPO. A copy of all json files is stored on the computer under `.minecraft\config\skyhanni\repo`. On every game start, the copy gets updated (if outdated and if not manually disabled). -When working with the repo, it is recommended to disable the manual repo update to prevent overriding your local changes -accidentally. +If you add stuff to the repo make sure it gets serialised. See the [jsonobjects](src/main/java/at/hannibal2/skyhanni/utils/jsonobjects) +folder for how to properly do this. You also may have to disable repo auto update in game. ### Discord IPC diff --git a/FEATURES.md b/FEATURES.md index 7393e3c4a8e5..6c0d616d9371 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -1,8 +1,10 @@ # SkyHanni - List of all Features Use `/sh` or `/skyhanni` to open the SkyHanni config in game. +
## Chat + + Options to change the player chat format (show prefix for channel 'all', hide player rank color, hide colon after player name, hide/change SkyBlock level format, hide/change elite position format, edit channel prefix design) @@ -37,8 +39,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. - Powder Mining messages hider - Winter gift messages hider - Many other messages (Not separated into own categories yet) +
+
## Dungeon + + Clicked Blocks (Showing the block behind walls AFTER clicked on a chest, Wither Essence or a lever) + Current milestone display. @@ -67,8 +72,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Color class levels in the tab list. (Also hide rank colors and emblems because who needs that in dungeons anyway?) + Soulweaver Skull Hider in the Dungeon Object Hider. - nea + Hide the annoying soulweaver skulls that float around you if you have the soulweaver gloves equipped. +
+
## Inventory + + Not Clickable Items + Mark items gray in your inventory when they are not supposed to be moved in certain GUIs, and make green lines @@ -115,16 +123,22 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Sack items can be crafted normally. + **Shift Click Equipment**. - Thunderblade73 + This removes the need to shift-click to swap the equipment items, without the annoying "pick up animation". +
+
## Item Abilities + + Show the **cooldown of items** in the inventory. - hannibal2 + Option to change the item background according to the cooldown. + Supports dungeon mage cooldown reduction. - Cad + Hiding the flame particles when using the Fire Veil Wand ability. + Circle around the player when having the Fire Veil Wand ability active. +
+
## Summoning Mobs + - Summoning Soul Display (Show the name of dropped soul lying on the ground, not working in dungeon when Skytils' "Hide Non-Starred Mobs Nametags" is enabled) @@ -132,8 +146,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. - Option to mark the own summoning mobs in green. - Summoning Mob Display (Show the health of your spawned summoning mobs listed in an extra GUI element and hiding the corresponding spawning/despawning chat messages) +
+
## Ashfang + - Show a cooldown when the player gets an ability block effect during the ashfang fight. - Display a timer until Ashfang brings his underlings back to him. @@ -143,8 +160,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. - Option to hide all the particles around the ashfang boss. - Option to hide the name of full health blazes around ashfang (only useful when highlight blazes is enabled) - Option to hide damage splashes around ashfang. +
+
## Minion + - A display that show the last time the hopper inside a minion has been emptied. - A marker to the last opened minion for a couple of seconds (seen through walls) @@ -154,8 +174,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. - Minion name display with minion tier. - **Minion Craft Helper** - Show how many more items you need to upgrade the minion in your inventory. Especially useful for bingo. +
+
## Bazaar + + Showing colors in the order inventory for outbid or fully bought/sold items. + Best Sell Method (Calculating the difference between instant-selling or using sell order for a selected bazaar item) @@ -163,8 +186,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Update Timer showing when the next api data update happens. + Price Website button. - hannibal2 + Adds a button to the bazaar product inventory that will open the item page in skyblock.bz. +
+
## Fishing + + **Trophy Counter** + After fishing a new trophy fish, showing you in chat how many more trophies you have collected in total. @@ -198,8 +224,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Display the Hypixel timer until the fishing hook can be pulled out of the water/lava, only bigger and on your screen. + Alerts when the player catches a Legendary Sea Creature. - Cad +
+
## Damage Indicator + - Show the remaining health of selected bosses in the game in a bigger GUI. - Send a chat message when the boss is healing himself. @@ -219,8 +248,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Show the amount of HP missing until the steak can be used on the vampire slayer on top of the boss. + Show a timer until the boss leaves the invincible Mania Circles state. + Show the percentage of HP next to the HP. +
+
## Slayer + + Hide poor slayer drop chat messages. + Slayer **Mini Boss:** @@ -285,20 +317,29 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + **Inquisitor Sharing** + Share aypoints for inquisitors you find with your party. + Show a timer until the inquisitor will despawn. +
+
## Marked Players + + Adding or removing players as marked with command /shmarkplayer + Highlight marked players in the world. + Highlight marked player names in chat. + Mark the own player name. +
+
## Bingo + + Shortens chat messages about skill level ups, collection gains and new area discoveries while on bingo. + Bingo Card +
+
## Mobs + + Arachne keeper highlighter. + Area boss highlighter. @@ -311,8 +352,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Countdown for Arachne spawn. - Cad + Supports quick spawns. + Option to hide the vanilla particles around enderman +
+
## Garden Features + + **Copper Price** - Show copper to coin prices inside the Sky Mart inventory. + **Visitor Display** - Show all items needed for the visitors. @@ -435,8 +479,12 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Option to send local contest data to elitebot.dev at the start of the new SkyBlock year. + **Visual garden plot borders** - VixidDev + Press F3 + G to enable/disable the view. ++ /shmouselock command to lock mouse rotation for farming. - Cad +
+
## The Rift + + **Rift Timer** + Show the remaining rift time, max time, percentage, and extra time changes. @@ -449,7 +497,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Highlight larvas on trees in Wyld Woods while holding a Larva Hook in the hand + Customize the color + **Odonatas Highlighter** - + Highlight the small Odonatas flying around the trees while holding a Empty Odonata Bottle in the hand. + + Highlight the small Odonatas flying around the trees while holding an Empty Odonata Bottle in the hand. + Customize the color + **Agaricus Cap** countdown + Counts down the time until Agaricus Cap (Mushroom) changes color from brown to red and is breakable. @@ -504,8 +552,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Option to hide the wilted berberis particles + **Horsezooka Hider** + Hide horses while holding the Horsezooka in the hand. +
+
## Mining + + **Highlight Commission Mobs** - hannibal2 + Highlight Mobs that are part of active commissions @@ -517,16 +568,25 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Fully customizable: change what items or stats to show. + Has support for the maxed Great Explorer perk. + Option to hide while not grinding powder. +
+
## Events + + Highlight Jerries during the Jerrypoclaypse. - Erymanthus + Show waypoints for Baskets of the Halloween Event in the main Hypixel lobby. - Erymanthus + Thanks Tobbbb for the coordinates! + Support for hiding basket waypoints once you have clicked on them. - hannibal2 + Option to show only the closest basket. - hannibal2 ++ Help with the 2023 Halloween visitor challenge (ephemeral dingsibumsi or something) - nea + + New Visitor Ping: Pings you when you are less than 10 seconds away from getting a new visitor. + + Accept Hotkey: Accept a visitor when you press this keybind while in the visitor GUI. +
+
## Commands + + **/shcommands** + Show all commands in SkyHanni @@ -541,8 +601,11 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + **/shfarmingprofile [player name]** + Opens the elitebot.dev website in your web browser to show your Farming Weight profile. + Tab Complete support to sacks command /gfs and /getfromsacks. - J10a1n15 +
+
## Misc + + Allow to paste text from clipboard in signs + Pet Display (showing the currently selected pet as GUI element, without any fancy XP or level or percentage, but with @@ -608,6 +671,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Can be disabled + Sortable by price or items stored (both desc/asc) + Option to show prices from Bazaar or NPC ++ Option to highlight items that are full in the sack inventory. + **Ghost Counter** (Contributed by HiZe) + Shows number of ghosts killed in the Mist in Dwarven Mines + Shows kill combo, coins per scavenger, all item drops, bestiarity, magic find and more @@ -694,9 +758,29 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Added In-Game Date display. - Erymanthus + Show the in-game date of SkyBlock (like in Apec, but with mild delays). + Includes the SkyBlock year. ++ Added **Dungeon party finder** QOL improvements - Cad + + Floor stack size. + + Mark Paid Carries red. + + Mark Low-Class levels orange. + + Mark groups you can't join dark red. + + Mark groups without your current classes green. ++ Added shortcuts for **Party commands** and smart **tab complete**. - CalMWolfs + + /pw -> party warp + + /pk -> party kick + + /pt -> party transfer + + /pp -> party promote + + /pko -> party kickoffline ++ Added working **Livid Finder** (should work 100% of the time). - hannibal2 + + Option to hide other/wrong/fake Livids (try this out and see if you really want this, it can be counter-productive + in some cases). ++ Added AFK time to Discord RPC. - NetheriteMiner +
+
## Cosmetics + + **Following Line** - hannibal2 + Draws a colored line behind the player. + Change the color, width, and duration of the line. +
diff --git a/build.gradle.kts b/build.gradle.kts index d4a851e13e61..18195f08568f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.21.Beta.8.1" +version = "0.21.Beta.13" // Toolchains: java { @@ -93,7 +93,12 @@ dependencies { shadowImpl("org.jetbrains.kotlin:kotlin-reflect:1.9.0") // testImplementation(kotlin("test")) + testImplementation("com.github.NotEnoughUpdates:NotEnoughUpdates:v2.1.1-alpha22:all") { + exclude(module = "unspecified") + isTransitive = false + } testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") + testImplementation("io.mockk:mockk:1.12.5") } tasks.withType(Test::class) { @@ -200,4 +205,4 @@ compileKotlin.kotlinOptions { val compileTestKotlin: KotlinCompile by tasks compileTestKotlin.kotlinOptions { jvmTarget = "1.8" -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index cb85a3fd61f1..2501d09059d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -53,16 +53,30 @@ import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider import at.hannibal2.skyhanni.features.chat.ChatFilter import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage +import at.hannibal2.skyhanni.features.chat.CompactSplashPotionMessage import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages import at.hannibal2.skyhanni.features.chat.WatchdogHider import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatModifier -import at.hannibal2.skyhanni.features.commands.PartyTransferCommand +import at.hannibal2.skyhanni.features.combat.BestiaryData +import at.hannibal2.skyhanni.features.combat.HideDamageSplash +import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter +import at.hannibal2.skyhanni.features.combat.mobs.AreaMiniBossFeatures +import at.hannibal2.skyhanni.features.combat.mobs.AshfangMinisNametagHider +import at.hannibal2.skyhanni.features.combat.mobs.MobHighlight +import at.hannibal2.skyhanni.features.combat.mobs.SpawnTimers +import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.SendCoordinatedCommand +import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand import at.hannibal2.skyhanni.features.commands.WarpIsCommand -import at.hannibal2.skyhanni.features.commands.WikiCommand +import at.hannibal2.skyhanni.features.commands.WikiManager +import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete +import at.hannibal2.skyhanni.features.commands.tabcomplete.PlayerTabComplete +import at.hannibal2.skyhanni.features.commands.tabcomplete.WarpTabComplete import at.hannibal2.skyhanni.features.cosmetics.CosmeticFollowingLine -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.features.cosmetics.ArrowTrail import at.hannibal2.skyhanni.features.dungeon.CroesusUnopenedChestTracker import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.dungeon.DungeonBossHideDamageSplash @@ -71,9 +85,9 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonChatFilter import at.hannibal2.skyhanni.features.dungeon.DungeonCleanEnd import at.hannibal2.skyhanni.features.dungeon.DungeonCopilot import at.hannibal2.skyhanni.features.dungeon.DungeonDeathCounter +import at.hannibal2.skyhanni.features.dungeon.DungeonFinderFeatures import at.hannibal2.skyhanni.features.dungeon.DungeonHideItems import at.hannibal2.skyhanni.features.dungeon.DungeonHighlightClickedBlocks -import at.hannibal2.skyhanni.features.dungeon.DungeonLevelColor import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder import at.hannibal2.skyhanni.features.dungeon.DungeonMilestonesDisplay import at.hannibal2.skyhanni.features.dungeon.DungeonRankTabListColor @@ -86,8 +100,10 @@ import at.hannibal2.skyhanni.features.event.diana.GriffinPetWarning import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow import at.hannibal2.skyhanni.features.event.jerry.HighlightJerries +import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder import at.hannibal2.skyhanni.features.fame.CityProjectFeatures +import at.hannibal2.skyhanni.features.fishing.ChumBucketHider import at.hannibal2.skyhanni.features.fishing.FishingHookDisplay import at.hannibal2.skyhanni.features.fishing.FishingTimer import at.hannibal2.skyhanni.features.fishing.SeaCreatureFeatures @@ -95,6 +111,7 @@ import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener import at.hannibal2.skyhanni.features.fishing.SharkFishCounter import at.hannibal2.skyhanni.features.fishing.ShowFishingItemName +import at.hannibal2.skyhanni.features.fishing.ThunderSparksHighlight import at.hannibal2.skyhanni.features.fishing.trophy.OdgerWaypoint import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishFillet import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager @@ -142,7 +159,10 @@ import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorDropStatistics import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer +import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter +import at.hannibal2.skyhanni.features.inventory.ChestValue +import at.hannibal2.skyhanni.features.inventory.HarpFeatures import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures @@ -153,34 +173,31 @@ import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper import at.hannibal2.skyhanni.features.inventory.StatsTuning +import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper +import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints +import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown import at.hannibal2.skyhanni.features.mainlobby.halloweenwaypoints.BasketWaypoints import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs import at.hannibal2.skyhanni.features.mining.KingTalismanHelper import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore +import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker import at.hannibal2.skyhanni.features.minion.MinionCollectLogic import at.hannibal2.skyhanni.features.minion.MinionFeatures -import at.hannibal2.skyhanni.features.misc.BestiaryData import at.hannibal2.skyhanni.features.misc.BrewingStandOverlay import at.hannibal2.skyhanni.features.misc.ButtonOnPause -import at.hannibal2.skyhanni.features.misc.ChestValue -import at.hannibal2.skyhanni.features.misc.ChickenHeadTimer -import at.hannibal2.skyhanni.features.misc.ChumBucketHider import at.hannibal2.skyhanni.features.misc.CollectionTracker -import at.hannibal2.skyhanni.features.misc.CompactSplashPotionMessage import at.hannibal2.skyhanni.features.misc.CurrentPetDisplay import at.hannibal2.skyhanni.features.misc.CustomTextBox -import at.hannibal2.skyhanni.features.misc.EnderNodeTracker import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider +import at.hannibal2.skyhanni.features.misc.FandomWikiFromMenus import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls -import at.hannibal2.skyhanni.features.misc.FrozenTreasureTracker -import at.hannibal2.skyhanni.features.misc.HarpFeatures import at.hannibal2.skyhanni.features.misc.HideArmor -import at.hannibal2.skyhanni.features.misc.HideDamageSplash import at.hannibal2.skyhanni.features.misc.InGameDateDisplay import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows import at.hannibal2.skyhanni.features.misc.LimboTimeTracker +import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.MiscFeatures import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay @@ -198,34 +215,23 @@ import at.hannibal2.skyhanni.features.misc.RestorePieceOfWizardPortalLore import at.hannibal2.skyhanni.features.misc.ServerRestartTitle import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert -import at.hannibal2.skyhanni.features.misc.ThunderSparksHighlight import at.hannibal2.skyhanni.features.misc.TimeFeatures import at.hannibal2.skyhanni.features.misc.TpsCounter +import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader import at.hannibal2.skyhanni.features.misc.compacttablist.TabListRenderer import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostCounter import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.features.misc.items.EstimatedWardrobePrice import at.hannibal2.skyhanni.features.misc.items.GlowingDroppedItems import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures -import at.hannibal2.skyhanni.features.misc.powdertracker.PowderTracker -import at.hannibal2.skyhanni.features.misc.tabcomplete.GetFromSacksTabComplete -import at.hannibal2.skyhanni.features.misc.tabcomplete.PlayerTabComplete -import at.hannibal2.skyhanni.features.misc.tabcomplete.WarpTabComplete import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadCompactName import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadInventoryNumber -import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper -import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayWaypoints import at.hannibal2.skyhanni.features.misc.trevor.TrevorFeatures import at.hannibal2.skyhanni.features.misc.trevor.TrevorSolver import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords -import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures -import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider -import at.hannibal2.skyhanni.features.mobs.MobHighlight -import at.hannibal2.skyhanni.features.mobs.SpawnTimers import at.hannibal2.skyhanni.features.nether.QuestItemHelper import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazes import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazingSouls @@ -313,14 +319,14 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.21.Beta.8.1", + version = "0.21.Beta.13", ) class SkyHanniMod { @Mod.EventHandler fun preInit(event: FMLPreInitializationEvent?) { checkIfNeuIsLoaded() - // utils + // data loadModule(this) loadModule(ChatManager) loadModule(HypixelData()) @@ -344,6 +350,7 @@ class SkyHanniMod { loadModule(RenderData()) loadModule(GardenCropMilestones) loadModule(GardenCropUpgrades()) + loadModule(VisitorListener()) loadModule(OwnInventoryData()) loadModule(ToolTipData()) loadModule(GuiEditManager()) @@ -360,6 +367,7 @@ class SkyHanniMod { loadModule(DefaultConfigFeatures) loadModule(EntityOutlineRenderer) loadModule(KeyboardManager) + loadModule(AdvancedPlayerList) // APIs loadModule(BazaarApi()) @@ -367,7 +375,7 @@ class SkyHanniMod { loadModule(CollectionAPI()) loadModule(FarmingContestAPI) loadModule(FriendAPI()) - loadModule(PartyAPI()) + loadModule(PartyAPI) loadModule(GuildAPI) loadModule(SlayerAPI) loadModule(PurseAPI()) @@ -385,6 +393,7 @@ class SkyHanniMod { loadModule(ItemDisplayOverlayFeatures()) loadModule(CurrentPetDisplay()) loadModule(ExpOrbsOnGroundHider()) + loadModule(FandomWikiFromMenus()) loadModule(DamageIndicatorManager()) loadModule(ItemAbilityCooldown()) loadModule(DungeonHighlightClickedBlocks()) @@ -393,14 +402,13 @@ class SkyHanniMod { loadModule(DungeonCleanEnd()) loadModule(DungeonBossMessages()) loadModule(DungeonBossHideDamageSplash()) - loadModule(TrophyFishManager()) + loadModule(TrophyFishManager) loadModule(TrophyFishFillet()) loadModule(TrophyFishMessages()) loadModule(BazaarBestSellMethod()) loadModule(BazaarOpenPriceWebsite()) loadModule(AnvilCombineHelper()) loadModule(SeaCreatureMessageShortener()) - // registerEvent(new GriffinBurrowFinder()); loadModule(AshfangFreezeCooldown()) loadModule(AshfangNextResetCooldown()) loadModule(SummoningSoulsName()) @@ -413,10 +421,11 @@ class SkyHanniMod { loadModule(MinionFeatures()) loadModule(TimeFeatures()) loadModule(RngMeterInventory()) - loadModule(WikiCommand()) + loadModule(WikiManager()) loadModule(SendCoordinatedCommand()) loadModule(WarpIsCommand()) - loadModule(PartyTransferCommand()) + loadModule(ViewRecipeCommand) + loadModule(PartyCommands) loadModule(SummoningMobManager()) loadModule(AreaMiniBossFeatures()) loadModule(MobHighlight()) @@ -450,7 +459,6 @@ class SkyHanniMod { loadModule(BurrowWarpHelper()) loadModule(CollectionTracker()) loadModule(HighlightBonzoMasks()) - loadModule(DungeonLevelColor()) loadModule(BazaarCancelledBuyOrderClipboard()) loadModule(CompactSplashPotionMessage()) loadModule(CroesusUnopenedChestTracker()) @@ -491,7 +499,7 @@ class SkyHanniMod { loadModule(FarmingArmorDrops()) loadModule(JoinCrystalHollows()) loadModule(CrystalHollowsNamesInCore()) - loadModule(GardenVisitorColorNames()) + loadModule(GardenVisitorColorNames) loadModule(TeleportPadCompactName()) loadModule(AnitaMedalProfit()) loadModule(AnitaExtraFarmingFortune()) @@ -508,7 +516,7 @@ class SkyHanniMod { loadModule(CropSpeedMeter()) loadModule(AshfangMinisNametagHider()) loadModule(TeleportPadInventoryNumber()) - loadModule(ComposterOverlay()) + loadModule(ComposterOverlay) loadModule(DiscordRPCManager) loadModule(GardenCropMilestoneFix()) loadModule(GardenBurrowingSporesNotifier()) @@ -602,7 +610,10 @@ class SkyHanniMod { loadModule(SkyBlockKickDuration()) loadModule(LimboTimeTracker()) loadModule(PartyMemberOutlines()) + loadModule(ArrowTrail()) loadModule(ShiftClickEquipment()) + loadModule(LockMouseLook) + loadModule(DungeonFinderFeatures()) init() @@ -680,4 +691,4 @@ class SkyHanniMod { logger.log(Level.INFO, message) } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 43ea964ee8a2..2476cbe73870 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class CollectionAPI { + // TODO USE SH-REPO private val counterPattern = "(?:.*) §e(?.*)§6\\/(?:.*)".toPattern() private val singleCounterPattern = "§7Total Collected: §e(?.*)".toPattern() @@ -66,6 +67,7 @@ class CollectionAPI { } companion object { + // TODO USE SH-REPO val collectionValue = mutableMapOf() private val collectionTier0Pattern = "§7Progress to .* I: .*".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 1ba66f1309ed..69a77d6dfc78 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - val configVersion = 4 + val configVersion = 6 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null @@ -94,4 +94,4 @@ object ConfigUpdaterMigrator { logger.log("Final config: $it") } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 9f14556055a7..21ed83b00a4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -8,10 +8,10 @@ import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.misc.EnderNode; -import at.hannibal2.skyhanni.features.misc.FrozenTreasure; -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData; -import at.hannibal2.skyhanni.features.misc.powdertracker.PowderChestReward; +import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNode; +import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure; +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; +import at.hannibal2.skyhanni.features.mining.powdertracker.PowderChestReward; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonTerminal; @@ -212,7 +212,7 @@ public static class VisitorDrops { public static class PlotIcon { @Expose - public Map plotList = new HashMap<>(); + public Map plotList = new HashMap<>(); } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 1479e5037257..3fdc56073367 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -2,12 +2,13 @@ package at.hannibal2.skyhanni.config.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigGuiManager -import at.hannibal2.skyhanni.config.commands.SimpleCommand.ProcessCommandRunnable import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder @@ -24,9 +25,9 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker +import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui import at.hannibal2.skyhanni.features.slayer.SlayerItemProfitTracker @@ -48,6 +49,7 @@ import net.minecraft.client.Minecraft import net.minecraft.command.ICommandSender import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent +import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText import net.minecraftforge.client.ClientCommandHandler @@ -82,7 +84,7 @@ object Commands { "A Command that is useful for monitoring/debugging existing features. §cIntended for developers only!" ), INTERNAL("§8", "Internal Command", "A Command that should §cnever §7be called manually!"), - + SHORTENED_COMMANDS("§b", "Shortened Commands", "Commands that shorten or improve existing Hypixel commands!") } class CommandInfo(val name: String, val description: String, val category: CommandCategory) @@ -107,6 +109,9 @@ object Commands { currentCategory = CommandCategory.INTERNAL internalCommands() + + currentCategory = CommandCategory.SHORTENED_COMMANDS + shortenedCommands() } private fun usersMain() { @@ -164,6 +169,10 @@ object Commands { // "Copies the translation for a given message to your clipboard. " + // "Language codes are at the end of the translation when you click on a message." // ) { Translator.fromEnglish(it) } + registerCommand( + "shmouselock", + "Lock/Unlock the mouse so it will no longer rotate the player (for farming)" + ) { LockMouseLook.toggleLock() } } private fun usersBugFix() { @@ -204,6 +213,10 @@ object Commands { "shcarrot", "Toggles receiving the 12 fortune from carrots" ) { CaptureFarmingGear.reverseCarrotFortune() } + registerCommand( + "shrepostatus", + "Shows the status of all the mods constants" + ) { SkyHanniMod.repo.displayRepoStatus(false) } } private fun developersDebugFeatures() { @@ -268,8 +281,8 @@ object Commands { "List persons into the chat SkyHanni thinks are in your party." ) { PartyAPI.listMembers() } registerCommand( - "shplaysound", - "Play the specified sound effect at the given pitch and volume." + "shplaysound", + "Play the specified sound effect at the given pitch and volume." ) { SoundUtils.command(it) } } @@ -278,12 +291,20 @@ object Commands { registerCommand("shcopyerror", "") { ErrorManager.command(it) } registerCommand("shstopcityprojectreminder", "") { CityProjectFeatures.disable() } registerCommand("shsendcontests", "") { GardenNextJacobContest.shareContestConfirmed(it) } + registerCommand("shwords", "Opens the config list for modifying visual words") { openVisualWords() } registerCommand("shstopaccountupgradereminder", "") { AccountUpgradeReminder.disable() } // registerCommand( // "shsendtranslation", // "Respond with a translation of the message that the user clicks" // ) { Translator.toEnglish(it) } - registerCommand("shwords", "Opens the config list for modifying visual words") { openVisualWords() } + } + + private fun shortenedCommands() { + registerCommand("pko", "Kicks offline party members") { PartyCommands.kickOffline() } + registerCommand("pw", "Warps your party") { PartyCommands.warp() } + registerCommand("pk", "Kick a specific party member") { PartyCommands.kick(it) } + registerCommand("pt", "Transfer the party to another party member") { PartyCommands.transfer(it) } + registerCommand("pp", "Promote a specific party member") { PartyCommands.promote(it) } } private fun commandHelp(args: Array) { @@ -348,11 +369,10 @@ object Commands { config.outdatedItems.clear() } - private fun registerCommand( - name: String, - description: String, - function: (Array) -> Unit - ) = registerCommand0(name, description, function) + private fun registerCommand(name: String, description: String, function: (Array) -> Unit) { + ClientCommandHandler.instance.registerCommand(SimpleCommand(name, createCommand(function))) + commands.add(CommandInfo(name, description, currentCategory)) + } private fun registerCommand0( name: String, @@ -360,19 +380,22 @@ object Commands { function: (Array) -> Unit, autoComplete: ((Array) -> List) = { listOf() } ) { - ClientCommandHandler.instance.registerCommand( - SimpleCommand( - name, - createCommand(function) - ) { _, b, _ -> autoComplete(b) } + val command = SimpleCommand( + name, + createCommand(function), + object : SimpleCommand.TabCompleteRunnable { + override fun tabComplete(sender: ICommandSender?, args: Array?, pos: BlockPos?): List { + return autoComplete(args ?: emptyArray()) + } + } ) + ClientCommandHandler.instance.registerCommand(command) commands.add(CommandInfo(name, description, currentCategory)) } - private fun createCommand(function: (Array) -> Unit) = - object : ProcessCommandRunnable() { - override fun processCommand(sender: ICommandSender?, args: Array) { - function(args.asList().toTypedArray()) - } + private fun createCommand(function: (Array) -> Unit) = object : SimpleCommand.ProcessCommandRunnable() { + override fun processCommand(sender: ICommandSender?, args: Array?) { + if (args != null) function(args.asList().toTypedArray()) } -} \ No newline at end of file + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java deleted file mode 100644 index 0bb0bd664b0a..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -package at.hannibal2.skyhanni.config.commands; - -import at.hannibal2.skyhanni.test.command.ErrorManager; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; - -import java.util.List; - -/** - * @author Moulberry - **/ -public class SimpleCommand extends CommandBase { - - private final String commandName; - private final ProcessCommandRunnable runnable; - private TabCompleteRunnable tabRunnable; - - public SimpleCommand(String commandName, ProcessCommandRunnable runnable) { - this.commandName = commandName; - this.runnable = runnable; - } - - public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) { - this.commandName = commandName; - this.runnable = runnable; - this.tabRunnable = tabRunnable; - } - - public abstract static class ProcessCommandRunnable { - - public abstract void processCommand(ICommandSender sender, String[] args); - } - - public interface TabCompleteRunnable { - - List tabComplete(ICommandSender sender, String[] args, BlockPos pos); - } - - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } - - public String getCommandName() { - return commandName; - } - - public String getCommandUsage(ICommandSender sender) { - return "/" + commandName; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - try { - runnable.processCommand(sender, args); - } catch (Throwable e) { - ErrorManager.INSTANCE.logError(e, "Error while running command /" + commandName); - } - } - - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos); - return null; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt new file mode 100644 index 000000000000..764f1243d583 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt @@ -0,0 +1,48 @@ +package at.hannibal2.skyhanni.config.commands + +import at.hannibal2.skyhanni.test.command.ErrorManager +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.util.BlockPos + +class SimpleCommand : CommandBase { + private val commandName: String + private val runnable: ProcessCommandRunnable + private var tabRunnable: TabCompleteRunnable? = null + + constructor(commandName: String, runnable: ProcessCommandRunnable) { + this.commandName = commandName + this.runnable = runnable + } + + constructor(commandName: String, runnable: ProcessCommandRunnable, tabRunnable: TabCompleteRunnable?) { + this.commandName = commandName + this.runnable = runnable + this.tabRunnable = tabRunnable + } + + abstract class ProcessCommandRunnable { + abstract fun processCommand(sender: ICommandSender?, args: Array?) + } + + interface TabCompleteRunnable { + fun tabComplete(sender: ICommandSender?, args: Array?, pos: BlockPos?): List + } + + override fun canCommandSenderUseCommand(sender: ICommandSender) = true + + override fun getCommandName() = commandName + + override fun getCommandUsage(sender: ICommandSender) = "/$commandName" + + override fun processCommand(sender: ICommandSender, args: Array) { + try { + runnable.processCommand(sender, args) + } catch (e: Throwable) { + ErrorManager.logError(e, "Error while running command /$commandName") + } + } + + override fun addTabCompletionOptions(sender: ICommandSender, args: Array, pos: BlockPos) = + if (tabRunnable != null) tabRunnable!!.tabComplete(sender, args, pos) else null +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java index 8168f98d07a4..d400c279f6d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java @@ -66,7 +66,7 @@ public static class FilterTypesConfig { @Expose @ConfigOption(name = "Powder Mining", desc = "Hide messages while opening chests in the Crystal Hollows. " + - "(Except powder numbers over 1k, Prehistoric Egg and Automaton Parts)") + "(Except powder numbers over 1k, essence numbers over 2, Prehistoric Eggs, and Automaton Parts)") @ConfigEditorBoolean @FeatureToggle public boolean powderMining = true; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java index a54feefe521f..458e3daf7de4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/CombatConfig.java @@ -2,8 +2,8 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostFormatting; -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil; +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostFormatting; +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java index 40248d74d15d..cb127dc11435 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java @@ -4,7 +4,9 @@ import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; import io.github.moulberry.moulconfig.annotations.ConfigOption; +import org.lwjgl.input.Keyboard; public class CommandsConfig { @@ -54,24 +56,60 @@ public static class TabCompleteConfig { @ConfigEditorBoolean @FeatureToggle public boolean gfsSack = true; + + @Expose + @ConfigOption(name = "Party Commands", desc = "Tab complete commonly used party commands.") + @ConfigEditorBoolean + @FeatureToggle + public boolean partyCommands = true; + + @Expose + @ConfigOption(name = "View Recipe", desc = "Tab complete item IDs in the the Hypixel command §e/viewrecipe§7. Only items with recipes are tab completed.") + @ConfigEditorBoolean + @FeatureToggle + public boolean viewrecipeItems = true; } + @ConfigOption(name = "Fandom Wiki for §e/wiki", desc = "") + @Accordion @Expose - @ConfigOption(name = "Fandom Wiki", desc = "Use Fandom wiki (§ehypixel-skyblock.fandom.com§7) instead of the Hypixel wiki (§ewiki.hypixel.net§7).") - @ConfigEditorBoolean - @FeatureToggle - public boolean useFandomWiki = false; + public FandomWikiCommmandConfig fandomWiki = new FandomWikiCommmandConfig(); + + public static class FandomWikiCommmandConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Use Fandom Wiki (§ehypixel-skyblock.fandom.com§7) instead of the Hypixel wiki (§ewiki.hypixel.net§7) in most wiki-related chat messages.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + @Expose + @ConfigOption(name = "Skip Chat", desc = "Directly opens the Fandom Wiki instead of sending the §e\"Click to search for this thing on the Fandom Wiki\"§7 message beforehand.") + @ConfigEditorBoolean + public boolean skipWikiChat = false; + + @Expose + @ConfigOption(name = "Fandom Wiki Key", desc = "Search for an item on Fandom Wiki with this keybind.\n§4For optimal experiences, do §lNOT§r §4bind this to a mouse button.") + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) + public int fandomWikiKeybind = Keyboard.KEY_NONE; + } + + @ConfigOption(name = "Party Commands", desc = "Shortens party commands and allows tab-completing for them. " + + "\n§eCommands: /pt /pp /pko /pk §7SkyBlock command §e/pt §7to check the play time still works.") @Expose - @ConfigOption(name = "Party transfer", desc = "Allows §e/pt §7as alias for §e/party transfer§7.\n" + - "§7SkyBlock command §e/pt §7to check the play time still works.") @ConfigEditorBoolean @FeatureToggle - public boolean usePartyTransferAlias = true; + public boolean shortCommands = true; @Expose @ConfigOption(name = "Replace Warp Is", desc = "Adds §e/warp is §7alongside §e/is§7. Idk why. Ask §cKaeso") @ConfigEditorBoolean @FeatureToggle public boolean replaceWarpIs = false; + + @Expose + @ConfigOption(name = "/viewrecipe Lower Case", desc = "Adds support for lower case item IDs to the Hypixel command §e/viewrecipe§7.") + @ConfigEditorBoolean + @FeatureToggle + public boolean viewRecipeLowerCase = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java index 489e26bb3049..90eee882a5f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DungeonConfig.java @@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class DungeonConfig { @@ -168,12 +169,42 @@ public static class DungeonCopilotConfig{ @ConfigOption(name = "Party Finder", desc = "") @Accordion public PartyFinderConfig partyFinder = new PartyFinderConfig(); + public static class PartyFinderConfig { @Expose @ConfigOption(name = "Colored Class Level", desc = "Color class levels in Party Finder.") @ConfigEditorBoolean @FeatureToggle public boolean coloredClassLevel = true; + + @Expose + @ConfigOption(name = "Floor Stack Size", desc = "Display the party finder floor as the item stack size.") + @ConfigEditorBoolean + @FeatureToggle + public boolean floorAsStackSize = true; + + @Expose + @ConfigOption(name = "Mark Paid Carries", desc = "Highlight paid carries with a red background to make them easier to find/skip.") + @ConfigEditorBoolean + @FeatureToggle + public boolean markPaidCarries = true; + + @Expose + @ConfigOption(name = "Mark Low Levels", desc = "Highlight groups with players at or below the specified class level to make them easier to find/skip.") + @ConfigEditorSlider(minValue = 0, maxValue = 50, minStep = 1) + public int markBelowClassLevel = 0; + + @Expose + @ConfigOption(name = "Mark Ineligible Groups", desc = "Highlight groups with requirements that you do not meet.") + @ConfigEditorBoolean + @FeatureToggle + public boolean markIneligibleGroups = true; + + @Expose + @ConfigOption(name = "Mark Missing Class", desc = "Highlight groups that don't currently have any members of your selected dungeon class.") + @ConfigEditorBoolean + @FeatureToggle + public boolean markMissingClass = true; } @Expose @@ -190,6 +221,25 @@ public static class TabListConfig { public boolean coloredClassLevel = true; } + @Expose + @ConfigOption(name = "Livid Finder", desc = "") + @Accordion + public LividFinderConfig lividFinder = new LividFinderConfig(); + + public static class LividFinderConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Helps find the correct livid in F5 and in M5.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Hide Wrong Livids", desc = "Hide wrong livids entirely.") + @ConfigEditorBoolean + public boolean hideWrong = false; + } + @Expose @ConfigOption(name = "Moving Skeleton Skulls", desc = "Highlight Skeleton Skulls when combining into an " + "orange Skeletor (not useful when combined with feature Hide Skeleton Skull).") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java index 8d8d186686ce..d550d3f72ac8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -73,10 +73,16 @@ public static class TimerConfig { @Expose @ConfigOption(name = "Sixth Visitor Warning", desc = "Notifies when it is believed that the sixth visitor has arrived. " + - "May be inaccurate with co-op members farming simultaneously.") + "May be inaccurate with co-op members farming simultaneously.") @ConfigEditorBoolean public boolean sixthVisitorWarning = true; + @Expose + @ConfigOption(name = "New Visitor Ping", desc = "Pings you when you are less than 10 seconds away from getting a new visitor. " + + "§eUseful for getting Ephemeral Gratitudes during the 2023 Halloween event.") + @ConfigEditorBoolean + public boolean newVisitorPing = false; + @Expose public Position pos = new Position(390, 65, false, true); } @@ -278,17 +284,17 @@ public static class DropsStatisticsConfig { "§647.2m Coins Spent", "§b23 §9Flowering Bouquet", "§b4 §9Overgrown Grass", - "§b2 §9Green Bandana", + "§b2 §5Green Bandana", "§b1 §9Dedication IV", - "§b6 §9Music Rune", + "§b6 §b◆ Music Rune I", "§b1 §cSpace Helmet", "§b1 §9Cultivating I", "§b1 §9Replenish I", " ", // If they want another empty row - "§212,735 Garden EXP", - "§b11,056 Bits", - "§250,556 Mithril Powder", - "§d50,556 Gemstone Powder", + "§212,600 Garden EXP", + "§b4.2k Bits", + "§220k Mithril Powder", + "§d18k Gemstone Powder", } ) public List textFormat = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12)); @@ -314,6 +320,17 @@ public static class DropsStatisticsConfig { @Expose public Position pos = new Position(5, 20, false, true); } + + @Expose + @ConfigOption( + name = "Accept Hotkey", + desc = "Accept a visitor when you press this keybind while in the visitor GUI. " + + "§eUseful for getting Ephemeral Gratitudes during the 2023 Halloween event." + ) + @ConfigEditorKeybind( + defaultKey = Keyboard.KEY_NONE + ) + public int acceptHotkey = Keyboard.KEY_NONE; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java index 7025dc2e0603..3c6c750565a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java @@ -159,11 +159,21 @@ public static class SackDisplayConfig { @FeatureToggle public boolean enabled = true; + @Expose + @ConfigOption( + name = "Highlight Full", + desc = "Highlight items that are full in red.\n" + + "§eDoes not need the option above to be enabled." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean highlightFull = true; + @Expose @ConfigOption(name = "Number Format", desc = "Either show Default, Formatted or Unformatted numbers.\n" + - "§eDefault: §72,240/2.2k\n" + - "§eFormatted: §72.2k/2.2k\n" + - "§eUnformatted: §72,240/2,200") + "§eDefault: §72,240/2.2k\n" + + "§eFormatted: §72.2k/2.2k\n" + + "§eUnformatted: §72,240/2,200") @ConfigEditorDropdown(values = {"Default", "Formatted", "Unformatted"}) public int numberFormat = 1; @@ -223,11 +233,17 @@ public static class SackDisplayConfig { public static class ChestValueConfig { @Expose - @ConfigOption(name = "Enabled", desc = "Enabled estimated value of chest") + @ConfigOption(name = "Enabled", desc = "Enable estimated value of chest.") @ConfigEditorBoolean @FeatureToggle public boolean enabled = false; + @Expose + @ConfigOption(name = "Enabled in dungeons", desc = "Enable the feature in dungeons.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enableInDungeons = false; + @Expose @ConfigOption(name = "Show Stacks", desc = "Show the item icon before name.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java index 38ac5f1d34ee..840096cac6e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java @@ -40,46 +40,49 @@ public static class PowderTrackerConfig { @Expose @ConfigOption( - name = "Text Format", - desc = "Drag text to change the appearance of the overlay." + name = "Text Format", + desc = "Drag text to change the appearance of the overlay." ) @ConfigEditorDraggableList( - exampleText = { - "§b§lPowder Tracker", - "§7Display Mode: §a[Total] §e[This Session]", - "§d852 Total chests Picked §7(950/h)", - "§bx2 Powder: §aActive!", - "§b250,420 §aMithril Powder §7(350,000/h)", - "§b250,420 §dGemstone Powder §7(350,000/h)", - "", - "§50§7-§90§7-§a0§f-0 §cRuby Gemstone", - "§50§7-§90§7-§a0§f-0 §bSapphire Gemstone", - "§50§7-§90§7-§a0§f-0 §6Amber Gemstone", - "§50§7-§90§7-§a0§f-0 §5Amethyst Gemstone", - "§50§7-§90§7-§a0§f-0 §aJade Gemstone", - "§50§7-§90§7-§a0§f-0 §eTopaz Gemstone", - - "§b14 §9FTX 3070", - "§b14 §9Electron Transmitter", - "§b14 §9Robotron Reflector", - "§b14 §9Superlite Motor", - "§b14 §9Control Switch", - "§b14 §9Synthetic Heart", - "§b14 §9Total Robot Parts", - - "§90§7-§a0§7-§c0§f-§e0§f-§30 §fGoblin Egg", - - "§b12 §aWishing Compass", - - "§b320 §aSludge Juice", - "§b2 §9Ascension Rope", - "§b6 §5Treasurite", - "§b4 §6Jungle Heart", - "§b1 §5Pickonimbus 2000", - "§b14 §aYoggie", - "§b9 §fPrehistoric Egg", - "§b25 §aOil Barrel" - } + exampleText = { + "§b§lPowder Tracker", + "§7Display Mode: §a[Total] §e[This Session]", + "§d852 Total chests Picked §7(950/h)", + "§bx2 Powder: §aActive!", + "§b250,420 §aMithril Powder §7(350,000/h)", + "§b250,420 §dGemstone Powder §7(350,000/h)", + "", + "§b129 §bDiamond Essence §7(600/h)", + "§b234 §6Gold Essence §7(700/h)", + "", + "§50§7-§90§7-§a0§f-0 §cRuby Gemstone", + "§50§7-§90§7-§a0§f-0 §bSapphire Gemstone", + "§50§7-§90§7-§a0§f-0 §6Amber Gemstone", + "§50§7-§90§7-§a0§f-0 §5Amethyst Gemstone", + "§50§7-§90§7-§a0§f-0 §aJade Gemstone", + "§50§7-§90§7-§a0§f-0 §eTopaz Gemstone", + + "§b14 §9FTX 3070", + "§b14 §9Electron Transmitter", + "§b14 §9Robotron Reflector", + "§b14 §9Superlite Motor", + "§b14 §9Control Switch", + "§b14 §9Synthetic Heart", + "§b14 §9Total Robot Parts", + + "§90§7-§a0§7-§c0§f-§e0§f-§30 §fGoblin Egg", + + "§b12 §aWishing Compass", + + "§b320 §aSludge Juice", + "§b2 §9Ascension Rope", + "§b6 §5Treasurite", + "§b4 §6Jungle Heart", + "§b1 §5Pickonimbus 2000", + "§b14 §aYoggie", + "§b9 §fPrehistoric Egg", + "§b25 §aOil Barrel" + } ) public Property> textFormat = Property.of(new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index ea9abf6259d6..86f60a8f7f46 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -258,9 +258,10 @@ public static class DiscordRPC { "Slayer", "Stacking Enchantment", "Dungeon", + "AFK Indicator" } ) - public List autoPriority = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); + public List autoPriority = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4)); @Expose @ConfigOption(name = "Dynamic Fallback", desc = "What to show when none of your \"Dynamic Priority\" statuses are active.") @@ -489,6 +490,49 @@ public static class FollowingLineConfig { @ConfigEditorBoolean public boolean behindBlocks = false; } + + @Expose + @ConfigOption(name = "Arrow Trail", desc = "") + @Accordion + public ArrowTrailConfig arrowTrailConfig = new ArrowTrailConfig(); + + public static class ArrowTrailConfig { + @Expose + @ConfigOption(name = "Enabled", desc = "Draw a colored line behind arrows in the air.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Hide Nonplayer Arrows", desc = "Only shows for arrows the player has shot.") + @ConfigEditorBoolean + public boolean hideOtherArrows = true; + + @Expose + @ConfigOption(name = "Arrow Color", desc = "Color of the line.") + @ConfigEditorColour + public String arrowColor = "0:200:85:255:85"; + + @Expose + @ConfigOption(name = "Player Arrows", desc = "Different color for the line of arrows that you have shot.") + @ConfigEditorBoolean + public boolean handlePlayerArrowsDifferently = false; + + @Expose + @ConfigOption(name = "Player Arrow Color", desc = "Color of the line of your own arrows.") + @ConfigEditorColour + public String playerArrowColor = "0:200:85:255:255"; + + @Expose + @ConfigOption(name = "Time Alive", desc = "Time in seconds until the trail fades out.") + @ConfigEditorSlider(minStep = 0.1f, minValue = 0.1f, maxValue = 10) + public float secondsAlive = 0.5f; + + @Expose + @ConfigOption(name = "Line Width", desc = "Width of the line.") + @ConfigEditorSlider(minStep = 1, minValue = 1, maxValue = 10) + public int lineWidth = 4; + } } @@ -624,9 +668,13 @@ public static class AdvancedPlayerList { public boolean markSpecialPersons = false; @Expose - @ConfigOption(name = "Mark SkyHanni Devs", desc = "Adds a §c:O §7behind the tablist name of SkyHanni's creators.") + @ConfigOption( + name = "Mark SkyHanni Devs", + desc = "Adds a §c:O §7behind the tablist name of §cSkyHanni's contributors§7. " + + "§eThose are the folks that coded the mod for you for free :)" + ) @ConfigEditorBoolean - public boolean markSkyHanniDevs = false; + public boolean markSkyHanniContributors = false; } } @@ -639,9 +687,9 @@ public static class KickDurationConfig { @Expose @ConfigOption( - name = "Enabled", - desc = "Show in the Hypixel lobby since when you were last kicked from SkyBlock (" + - "useful if you get blocked because of '§cYou were kicked while joining that server!§7')." + name = "Enabled", + desc = "Show in the Hypixel lobby since when you were last kicked from SkyBlock (" + + "useful if you get blocked because of '§cYou were kicked while joining that server!§7')." ) @ConfigEditorBoolean @FeatureToggle @@ -650,9 +698,9 @@ public static class KickDurationConfig { @Expose @ConfigOption(name = "Warn Time", desc = "Send warning and sound this seconds after a SkyBlock kick.") @ConfigEditorSlider( - minValue = 5, - maxValue = 300, - minStep = 1 + minValue = 5, + maxValue = 300, + minStep = 1 ) public Property warnTime = Property.of(60); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 6ac5f7452c53..9021ec9be230 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -138,7 +138,7 @@ public static class LarvasConfig { public static class OdonataConfig { @Expose - @ConfigOption(name = "Highlight", desc = "Highlight the small §cOdonatas §7flying around the trees while holding a " + + @ConfigOption(name = "Highlight", desc = "Highlight the small §cOdonatas §7flying around the trees while holding an " + "§eEmpty Odonata Bottle §7in the hand.") @ConfigEditorBoolean @FeatureToggle @@ -693,6 +693,11 @@ public static class MotesOrbsConfig { @FeatureToggle public boolean enabled = true; + @Expose + @ConfigOption(name = "Highlight Size", desc = "Set render size for highlighted Motes Orbs.") + @ConfigEditorSlider(minStep = 1, minValue = 1, maxValue = 5) + public int size = 3; + @Expose @ConfigOption(name = "Hide Particles", desc = "Hide normal Motes Orbs particles.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt index 873119171ddb..cddf83d0bdcb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ActionBarStatsData { + // TODO USE SH-REPO private val patterns = mapOf( "health" to "§[c6](?[\\d,]+)/[\\d,]+❤.*".toPattern(), "defense" to ".*§a(?[\\d,]+)§a❈.*".toPattern(), diff --git a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt index ca2557af00a9..5b32a1d15d68 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.jsonobjects.BingoRanks +import at.hannibal2.skyhanni.utils.jsonobjects.BingoRanksJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object BingoAPI { @@ -9,13 +9,11 @@ object BingoAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant("BingoRanks")?.let { - ranks = it.ranks - } + ranks = event.getConstant("BingoRanks").ranks } fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value fun getIcon(searchRank: Int) = ranks.entries.find { it.value == searchRank }?.key -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index 83853ef59187..021e59b91cb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -19,6 +19,7 @@ import java.io.ByteArrayInputStream import java.util.Base64 class CropAccessoryData { + // TODO USE SH-REPO private val accessoryBagNamePattern = "Accessory Bag \\((\\d)/(\\d)\\)".toRegex() private var loadedAccessoryThisProfile = false private var ticks = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index 26a4046dd633..bca06d18cd76 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -17,6 +17,8 @@ import java.util.UUID class FriendAPI { private val file = File("config/skyhanni/friends.json") + + // TODO USE SH-REPO private val removedFriendPattern = ".*\n§r§eYou removed §r(?.*)§e from your friends list!§r§9§m\n.*".toPattern() private val addedFriendPattern = "§aYou are now friends with (?.*)".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index 277fdb56c88e..ecbaee59153a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object GardenCropMilestones { + // TODO USE SH-REPO private val cropPattern = "§7Harvest §f(?.*) §7on .*".toPattern() private val totalPattern = "§7Total: §a(?.*)".toPattern() @@ -41,7 +42,7 @@ object GardenCropMilestones { CropMilestoneUpdateEvent().postAndCatch() } - private var cropMilestoneData: Map>? = null + private var cropMilestoneData: Map> = emptyMap() val cropCounter: MutableMap? get() = GardenAPI.config?.cropCounter @@ -53,14 +54,14 @@ object GardenCropMilestones { } fun CropType.isMaxed(): Boolean { - val maxValue = cropMilestoneData?.get(this)?.sum() ?: 1_000_000_000 // 1 bil for now + val maxValue = cropMilestoneData[this]?.sum() ?: 1_000_000_000 // 1 bil for now return getCounter() >= maxValue } fun getTierForCropCount(count: Long, crop: CropType): Int { var tier = 0 var totalCrops = 0L - val cropMilestone = cropMilestoneData?.get(crop) ?: return 0 + val cropMilestone = cropMilestoneData[crop] ?: return 0 for (tierCrops in cropMilestone) { totalCrops += tierCrops if (totalCrops > count) { @@ -72,12 +73,12 @@ object GardenCropMilestones { return tier } - fun getMaxTier() = cropMilestoneData?.values?.firstOrNull()?.size ?: 0 + fun getMaxTier() = cropMilestoneData.values.firstOrNull()?.size ?: 0 fun getCropsForTier(requestedTier: Int, crop: CropType): Long { var totalCrops = 0L var tier = 0 - val cropMilestone = cropMilestoneData?.get(crop) ?: return 0 + val cropMilestone = cropMilestoneData[crop] ?: return 0 for (tierCrops in cropMilestone) { totalCrops += tierCrops tier++ @@ -99,7 +100,6 @@ object GardenCropMilestones { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant("Garden") ?: return - cropMilestoneData = data.crop_milestones + cropMilestoneData = event.getConstant("Garden").crop_milestones } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt index b1d1d3bf6864..15a18ca26d25 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GardenCropUpgrades { + // TODO USE SH-REPO private val tierPattern = "§7Current Tier: §[0-9a-e](\\d)§7/§a9".toRegex() private val chatUpgradePattern = " {2}§r§6§lCROP UPGRADE §e§f([\\w ]+)§7 #(\\d)".toRegex() diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index e8ca2ab3b6d9..31bb7c04725f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -18,6 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent class HypixelData { + // TODO USE SH-REPO private val tabListProfilePattern = "§e§lProfile: §r§a(?.*)".toPattern() private val westVillageFarmArea = AxisAlignedBB(-54.0, 69.0, -115.0, -40.0, 75.0, -127.0) private val howlingCaveArea = AxisAlignedBB(-401.0, 50.0, -104.0, -337.0, 90.0, 36.0) @@ -102,6 +104,7 @@ class HypixelData { checkHypixel() if (LorenzUtils.onHypixel) { HypixelJoinEvent().postAndCatch() + SkyHanniMod.repo.displayRepoStatus(true) } } if (!LorenzUtils.onHypixel) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index af968d62e362..15195dec4a69 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data enum class IslandType(val displayName: String, val apiName: String = "null") { + // TODO USE SH-REPO (for displayName only) PRIVATE_ISLAND("Private Island"), PRIVATE_ISLAND_GUEST("Private Island Guest"), THE_END("The End"), @@ -31,4 +32,4 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { return entries.firstOrNull { it.displayName == name } ?: UNKNOWN } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt index 2508391d985b..d4ad57e2d531 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt @@ -15,6 +15,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class MayorElection { private var lastUpdate = 0L + private var dispatcher = Dispatchers.IO companion object { var rawMayorData: MayorJson? = null @@ -40,7 +41,7 @@ class MayorElection { lastUpdate = System.currentTimeMillis() SkyHanniMod.coroutineScope.launch { val url = "https://api.hypixel.net/resources/skyblock/election" - val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } + val jsonObject = withContext(dispatcher) { APIUtil.getJSONResponse(url) } rawMayorData = ConfigManager.gson.fromJson(jsonObject, MayorJson::class.java) val data = rawMayorData ?: return@launch val map = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index e00ea2c51843..08344c51bb17 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -12,21 +12,39 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.random.Random -class PartyAPI { - companion object { - fun listMembers() { - LorenzUtils.chat("§a[SkyHanni] Tracked party members §7(${partyMembers.size}) §f:") - for (member in partyMembers) { - LorenzUtils.chat(" §a- §7$member") - } +object PartyAPI { + // TODO USE SH-REPO + private val youJoinedPartyPattern = "§eYou have joined (?.*)'s §eparty!".toPattern() + private val othersJoinedPartyPattern = "(?.*) §ejoined the party.".toPattern() + private val othersInThePartyPattern = "§eYou'll be partying with: (?.*)".toPattern() + private val otherLeftPattern = "(?.*) §ehas left the party.".toPattern() + private val otherKickedPattern = "(?.*) §ehas been removed from the party.".toPattern() + private val otherOfflineKickedPattern = "§eKicked (?.*) because they were offline.".toPattern() + private val otherDisconnectedPattern = + "(?.*) §ewas removed from your party because they disconnected.".toPattern() + private val transferPattern = "The party was transferred to .* because (?.*) left".toPattern() + private val disbandedPattern = ".* §ehas disbanded the party!".toPattern() + private val kickedPattern = "§eYou have been kicked from the party by .* §e".toPattern() + private val partyMembersStartPattern = "§6Party Members \\(\\d+\\)".toPattern() + private val partyMemberListPattern = "Party (?:Leader|Moderators|Members): (?.*)".toPattern() - if (Random.nextDouble() < 0.1) { - OSUtils.openBrowser("https://www.youtube.com/watch?v=iANP7ib7CPA") - LorenzUtils.hoverableChat("§7Are You Ready To Party?", listOf("§b~Spongebob")) - } + val partyMembers = mutableListOf() + + fun listMembers() { + val size = partyMembers.size + if (size == 0) { + LorenzUtils.chat("§e[SkyHanni] No tracked party members!") + return + } + LorenzUtils.chat("§a[SkyHanni] Tracked party members §7($size) §f:") + for (member in partyMembers) { + LorenzUtils.chat(" §a- §7$member") } - val partyMembers = mutableListOf() + if (Random.nextDouble() < 0.1) { + OSUtils.openBrowser("https://www.youtube.com/watch?v=iANP7ib7CPA") + LorenzUtils.hoverableChat("§7Are You Ready To Party?", listOf("§b~Spongebob")) + } } @SubscribeEvent @@ -34,15 +52,16 @@ class PartyAPI { val message = event.message.trimWhiteSpaceAndResets().removeResets() // new member joined - "§eYou have joined (?.*)'s §eparty!".toPattern().matchMatcher(message) { + + youJoinedPartyPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() if (!partyMembers.contains(name)) partyMembers.add(name) } - "(?.*) §ejoined the party.".toPattern().matchMatcher(message) { + othersJoinedPartyPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() if (!partyMembers.contains(name)) partyMembers.add(name) } - "§eYou'll be partying with: (?.*)".toPattern().matchMatcher(message) { + othersInThePartyPattern.matchMatcher(message) { for (name in group("names").split(", ")) { val playerName = name.cleanPlayerName() if (!partyMembers.contains(playerName)) partyMembers.add(playerName) @@ -50,32 +69,32 @@ class PartyAPI { } // one member got removed - "(?.*) §ehas left the party.".toPattern().matchMatcher(message) { + otherLeftPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "(?.*) §ehas been removed from the party.".toPattern().matchMatcher(message) { + otherKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "§eKicked (?.*) because they were offline.".toPattern().matchMatcher(message) { + otherOfflineKickedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "(?.*) §ewas removed from your party because they disconnected.".toPattern().matchMatcher(message) { + otherDisconnectedPattern.matchMatcher(message) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } - "The party was transferred to .* because (?.*) left".toPattern().matchMatcher(message.removeColor()) { + transferPattern.matchMatcher(message.removeColor()) { val name = group("name").cleanPlayerName() partyMembers.remove(name) } // party disbanded - ".* §ehas disbanded the party!".toPattern().matchMatcher(message) { + disbandedPattern.matchMatcher(message) { partyMembers.clear() } - "§eYou have been kicked from the party by .* §e".toPattern().matchMatcher(message) { + kickedPattern.matchMatcher(message) { partyMembers.clear() } if (message == "§eYou left the party." || @@ -86,11 +105,11 @@ class PartyAPI { } // party list - "§6Party Members \\(\\d+\\)".toPattern().matchMatcher(message.removeResets()) { + partyMembersStartPattern.matchMatcher(message.removeResets()) { partyMembers.clear() } - "Party (?:Leader|Moderators|Members): (?.*)".toPattern().matchMatcher(message.removeColor()) { + partyMemberListPattern.matchMatcher(message.removeColor()) { for (name in group("names").split(" ● ")) { val playerName = name.replace(" ●", "").cleanPlayerName() if (playerName == Minecraft.getMinecraft().thePlayer.name) continue @@ -98,4 +117,4 @@ class PartyAPI { } } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 2b4fcd7a8714..63f77f2d2f4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -31,6 +31,7 @@ object ProfileStorageData { @SubscribeEvent(priority = EventPriority.HIGHEST) fun onChat(event: LorenzChatEvent) { + // TODO USE SH-REPO "§7Switching to profile (?.*)\\.\\.\\.".toPattern().matchMatcher(event.message) { nextProfile = group("name").lowercase() loaded = false diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index d41e5ad7af0e..cb3b2103197e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -10,6 +10,7 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PurseAPI { + // TODO USE SH-REPO private val pattern = "(Piggy|Purse): §6(?[\\d,]*).*".toPattern() private var currentPurse = 0.0 private var inventoryCloseTime = 0L diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt index 0137c4491548..f109ea01b897 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt @@ -2,9 +2,8 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI -import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui +import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.gui.inventory.GuiInventory @@ -20,7 +19,7 @@ class RenderData { fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return if (!SkyHanniDebugsAndTests.globalRender) return - if (GuiEditManager.isInGui() || FFGuideGUI.isInGui() || VisualWordGui.isInGui()) return + if (GuiEditManager.isInGui() || VisualWordGui.isInGui()) return GuiRenderEvent.GuiOverlayRenderEvent().postAndCatch() } @@ -28,7 +27,7 @@ class RenderData { @SubscribeEvent fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { if (!SkyHanniDebugsAndTests.globalRender) return - if (GuiEditManager.isInGui() || FFGuideGUI.isInGui() || VisualWordGui.isInGui()) return + if (GuiEditManager.isInGui() || VisualWordGui.isInGui()) return val currentScreen = Minecraft.getMinecraft().currentScreen ?: return if (currentScreen !is GuiInventory && currentScreen !is GuiChest) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 9e2e4a7fa295..59d250b0ad81 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -6,9 +6,11 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SackChangeEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -24,13 +26,13 @@ import com.google.gson.annotations.Expose import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - object SackAPI { private val sackDisplayConfig get() = SkyHanniMod.feature.inventory.sackDisplay private val chatConfig get() = SkyHanniMod.feature.chat private var lastOpenedInventory = "" var inSackInventory = false + // TODO USE SH-REPO private val sackPattern = "^(.* Sack|Enchanted .* Sack)$".toPattern() private val numPattern = "(?:(?:§[0-9a-f](?I{1,3})§7:)?|(?:§7Stored:)?) (?§[0-9a-f])(?[0-9.,kKmMbB]+)§7/(?\\d+(?:[0-9.,]+)?[kKmMbB]?)".toPattern() @@ -153,15 +155,22 @@ object SackAPI { item.colorCode = group("color") item.stored = stored item.total = group("total") + if (savingSacks) setSackItem(item.internalName, item.stored.formatNumber()) item.price = if (isTrophySack) { - val trophyName = - internalName.asString().lowercase().substringBeforeLast("_").replace("_", "") - val filletValue = - TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0 - val storedNumber = stored.formatNumber() - "MAGMA_FISH".asInternalName().sackPrice((filletValue * storedNumber).toString()) - } else internalName.sackPrice(stored).coerceAtLeast(0) + val internal = stack.getInternalName_old() + val trophyFishName = internal.substringBeforeLast("_") + .replace("_", "").lowercase() + val trophyRarityName = internal.substringAfterLast("_") + val info = TrophyFishManager.getInfo(trophyFishName) + val rarity = TrophyRarity.getByName(trophyRarityName) ?: TrophyRarity.BRONZE + val filletValue = (info?.getFilletValue(rarity) ?: 0) * stored.formatNumber() + item.magmaFish = filletValue + "MAGMA_FISH".asInternalName().sackPrice(filletValue.toString()) + } else { + internalName.sackPrice(stored).coerceAtLeast(0) + } + if (isRuneSack) { val level = group("level") @@ -224,20 +233,21 @@ object SackAPI { val internalName = NEUInternalName.fromItemName(item) sackChanges.add(SackChange(delta, internalName, sacks)) } - SackChangeEvent(sackChanges, otherItemsAdded, otherItemsRemoved).postAndCatch() + val sackEvent = SackChangeEvent(sackChanges, otherItemsAdded, otherItemsRemoved) + updateSacks(sackEvent) + sackEvent.postAndCatch() if (chatConfig.hideSacksChange) { event.blockedReason = "sacks_change" } } - @SubscribeEvent - fun sackChange(event: SackChangeEvent) { + private fun updateSacks(changes: SackChangeEvent) { sackData = ProfileStorageData.sackProfiles?.sackContents ?: return // if it gets added and subtracted but only 1 shows it will be outdated val justChanged = mutableMapOf() - for (change in event.sackChanges) { + for (change in changes.sackChanges) { if (change.internalName in justChanged) { justChanged[change.internalName] = (justChanged[change.internalName] ?: 0) + change.delta } else { @@ -254,36 +264,37 @@ object SackAPI { newAmount = 0 changed = 0 } - sackData = sackData.editCopy { this[item.key] = SackItem(newAmount, changed, oldData.outdatedStatus) } + sackData = sackData.editCopy { this[item.key] = SackItem(newAmount, changed, oldData.getStatus()) } } else { val newAmount = if (item.value > 0) item.value else 0 - sackData = sackData.editCopy { this[item.key] = SackItem(newAmount.toLong(), newAmount, 2) } + sackData = + sackData.editCopy { this[item.key] = SackItem(newAmount.toLong(), newAmount, SackStatus.OUTDATED) } } } - if (event.otherItemsAdded || event.otherItemsRemoved) { + if (changes.otherItemsAdded || changes.otherItemsRemoved) { for (item in sackData) { if (item.key in justChanged) continue val oldData = sackData[item.key] - sackData = sackData.editCopy { this[item.key] = SackItem(oldData!!.amount, 0, 1) } + sackData = sackData.editCopy { this[item.key] = SackItem(oldData!!.amount, 0, SackStatus.ALRIGHT) } } } saveSackData() } private fun setSackItem(item: NEUInternalName, amount: Long) { - sackData = sackData.editCopy { this[item] = SackItem(amount, 0, 0) } + sackData = sackData.editCopy { this[item] = SackItem(amount, 0, SackStatus.CORRECT) } } fun fetchSackItem(item: NEUInternalName): SackItem { - sackData = ProfileStorageData.sackProfiles?.sackContents ?: return SackItem(0, 0, -1) + sackData = ProfileStorageData.sackProfiles?.sackContents ?: return SackItem(0, 0, SackStatus.MISSING) if (sackData.containsKey(item)) { - return sackData[item] ?: return SackItem(0, 0, -1) + return sackData[item] ?: return SackItem(0, 0, SackStatus.MISSING) } - sackData = sackData.editCopy { this[item] = SackItem(0, 0, 2) } - return sackData[item] ?: return SackItem(0, 0, -1) + sackData = sackData.editCopy { this[item] = SackItem(0, 0, SackStatus.OUTDATED) } + return sackData[item] ?: return SackItem(0, 0, SackStatus.MISSING) } fun commandGetFromSacks(item: String, amount: Int) = LorenzUtils.sendCommandToServer("gfs $item $amount") @@ -318,17 +329,18 @@ object SackAPI { var stored: String = "0", var total: String = "0", var price: Long = 0, + var magmaFish: Long = 0, ) } -// status -1 = fetching data failed, 0 = < 1% of being wrong, 1 = 10% of being wrong, 2 = is 100% wrong -// lastChange is set to 0 when value is refreshed in the sacks gui and when being set initially -// if it didn't change in an update the lastChange value will stay the same and not be set to 0 data class SackItem( @Expose val amount: Long, @Expose val lastChange: Int, - @Expose val outdatedStatus: Int -) + @Expose private val status: SackStatus? +) { + fun getStatus() = status ?: SackStatus.MISSING +} + private val gemstoneMap = mapOf( "Jade Gemstones" to "ROUGH_JADE_GEM".asInternalName(), @@ -340,3 +352,11 @@ private val gemstoneMap = mapOf( "Ruby Gemstones" to "ROUGH_RUBY_GEM".asInternalName(), "Opal Gemstones" to "ROUGH_OPAL_GEM".asInternalName(), ) + +// ideally should be correct but using alright should also be fine unless they sold their whole sacks +enum class SackStatus { + MISSING, + CORRECT, + ALRIGHT, + OUTDATED; +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 62c0a5503ac0..71d84328c94a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ScoreboardData { companion object { + // TODO USE SH-REPO private val splitIcons = listOf( "\uD83C\uDF6B", "\uD83D\uDCA3", diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt index c847c17103be..78c25e79975e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SkillExperience { + // TODO USE SH-REPO private val actionBarPattern = ".*§3\\+.* (?.*) \\((?.*)/(?.*)\\).*".toPattern() private val inventoryPattern = ".* §e(?.*)§6/.*".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index e02bc693d8f9..f3c23700daa7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -146,6 +146,7 @@ object SlayerAPI { } } + // TODO USE SH-REPO fun getSlayerTypeForCurrentArea() = when (LorenzUtils.skyBlockArea) { "Graveyard", "Coal Mine", diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt index f9f33d6cf640..4712689dc335 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/ComposterUpgrade.kt @@ -10,7 +10,7 @@ enum class ComposterUpgrade(val displayName: String, val slotNumber: Int) { companion object { private fun regexValues() = entries.joinToString("|") { it.displayName } - + // TODO USE SH-REPO val regex = "§a(?${regexValues()})(?: (?.*))?".toPattern() fun getByName(name: String) = entries.firstOrNull { it.displayName == name } diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt new file mode 100644 index 000000000000..60606ffa9c24 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.data.repo + +class RepoError : Error { + constructor(errorMessage: String) : super(errorMessage) + constructor(errorMessage: String, cause: Throwable) : super(errorMessage, cause) +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index ed35272cdd6b..593d9a65241c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -25,6 +25,21 @@ class RepoManager(private val configLocation: File) { private val gson get() = ConfigManager.gson private var latestRepoCommit: String? = null private val repoLocation: File = File(configLocation, "repo") + private var error = false + + companion object { + val successfulConstants = mutableListOf() + val unsuccessfulConstants = mutableListOf() + + private var lastConstant: String? = null + + fun setlastConstant(constant: String) { + lastConstant?.let { + successfulConstants.add(it) + } + lastConstant = constant + } + } fun loadRepoInformation() { atomicShouldManuallyReload.set(true) @@ -39,12 +54,12 @@ class RepoManager(private val configLocation: File) { fun updateRepo() { atomicShouldManuallyReload.set(true) - fetchRepository(true).thenRun { this.reloadRepository("Repo updated successful :)") } + fetchRepository(true).thenRun { this.reloadRepository("Repo updated successful.") } } fun reloadLocalRepo() { atomicShouldManuallyReload.set(true) - reloadRepository("Repo loaded from local files successful :)") + reloadRepository("Repo loaded from local files successful.") } private fun fetchRepository(command: Boolean): CompletableFuture { @@ -62,12 +77,17 @@ class RepoManager(private val configLocation: File) { e.printStackTrace() } if (latestRepoCommit == null || latestRepoCommit!!.isEmpty()) return@supplyAsync false - if (File(configLocation, "repo").exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit) { - if (command) { - LorenzUtils.chat("§e[SkyHanni] §7The repo is already up to date!") - atomicShouldManuallyReload.set(false) + val file = File(configLocation, "repo") + if (file.exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit + ) { + if (unsuccessfulConstants.isEmpty()) { + + if (command) { + LorenzUtils.chat("§e[SkyHanni] §7The repo is already up to date!") + atomicShouldManuallyReload.set(false) + } + return@supplyAsync false } - return@supplyAsync false } RepoUtils.recursiveDelete(repoLocation) repoLocation.mkdirs() @@ -120,20 +140,63 @@ class RepoManager(private val configLocation: File) { private fun reloadRepository(answerMessage: String = ""): CompletableFuture { val comp = CompletableFuture() if (!atomicShouldManuallyReload.get()) return comp + ErrorManager.resetCache() Minecraft.getMinecraft().addScheduledTask { - try { - RepositoryReloadEvent(repoLocation, gson).postAndCatch() - comp.complete(null) - if (answerMessage.isNotEmpty()) { - LorenzUtils.chat("§e[SkyHanni] §a$answerMessage") + error = false + successfulConstants.clear() + unsuccessfulConstants.clear() + lastConstant = null + + RepositoryReloadEvent(repoLocation, gson).postAndCatchAndBlock(ignoreErrorCache = true) { + error = true + lastConstant?.let { + unsuccessfulConstants.add(it) + } + lastConstant = null + } + comp.complete(null) + if (answerMessage.isNotEmpty() && !error) { + LorenzUtils.chat("§e[SkyHanni] §a$answerMessage") + } + if (error) { + LorenzUtils.clickableChat( + "§e[SkyHanni] Error with the repo detected, try /shupdaterepo to fix it!", + "shupdaterepo" + ) + if (unsuccessfulConstants.isEmpty()) { + unsuccessfulConstants.add("All Constants") } - } catch (e: java.lang.Exception) { - ErrorManager.logError(e, "Error reading repo data!") } } return comp } + fun displayRepoStatus(joinEvent: Boolean) { + if (joinEvent) { + if (unsuccessfulConstants.isNotEmpty()) { + LorenzUtils.chat("§c[SkyHanni] §7Repo Issue! Some features may not work. Please report this error on the Discord!") + LorenzUtils.chat("§7Repo Auto Update Value: §c${SkyHanniMod.feature.dev.repoAutoUpdate}") + LorenzUtils.chat("§7If you have Repo Auto Update turned off, please try turning that on.\n§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):") + for (constant in unsuccessfulConstants) { + LorenzUtils.chat(" §e- §7$constant") + } + } + return + } + if (unsuccessfulConstants.isEmpty() && successfulConstants.isNotEmpty()) { + LorenzUtils.chat("§a[SkyHanni] Repo working fine!") + return + } + if (successfulConstants.isNotEmpty()) LorenzUtils.chat("§a[SkyHanni] Successful Constants §7(${successfulConstants.size}):") + for (constant in successfulConstants) { + LorenzUtils.chat(" §a- §7$constant") + } + LorenzUtils.chat("§c[SkyHanni] Unsuccessful Constants §7(${unsuccessfulConstants.size}):") + for (constant in unsuccessfulConstants) { + LorenzUtils.chat(" §e- §7$constant") + } + } + /** * Parses a file in to a JsonObject. */ @@ -175,4 +238,4 @@ class RepoManager(private val configLocation: File) { ) ).use { writer -> writer.write(gson.toJson(json)) } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 2438a9be383d..7ec70c673551 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.data.repo -import at.hannibal2.skyhanni.test.command.ErrorManager import com.google.gson.Gson import java.io.BufferedReader import java.io.File @@ -8,10 +7,10 @@ import java.io.FileInputStream import java.io.FileOutputStream import java.io.IOException import java.io.InputStreamReader +import java.lang.reflect.Type import java.nio.charset.StandardCharsets import java.nio.file.Files import java.util.zip.ZipInputStream -import java.lang.reflect.Type object RepoUtils { @@ -84,23 +83,13 @@ object RepoUtils { return false } - fun getConstant(repo: File, constant: String, gson: Gson, clazz: Class?, type: Type? = null): T? { - if (!repo.exists()) return null - - val jsonFile = File(repo, "constants/$constant.json") + fun getConstant(repoLocation: File, constant: String, gson: Gson, clazz: Class?, type: Type? = null): T { + val name = "constants/$constant.json" + val jsonFile = File(repoLocation, name) if (!jsonFile.isFile) { - ErrorManager.logError( - Error("File '$jsonFile' not found!"), - "File in repo missing! ($jsonFile). Try §e/shupdaterepo" - ) - return null + throw RepoError("Repo file '$name' not found.") } - BufferedReader( - InputStreamReader( - FileInputStream(jsonFile), - StandardCharsets.UTF_8 - ) - ).use { reader -> + BufferedReader(InputStreamReader(FileInputStream(jsonFile), StandardCharsets.UTF_8)).use { reader -> if (type == null) { return gson.fromJson(reader, clazz) } else { @@ -108,4 +97,4 @@ object RepoUtils { } } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/BossHealthChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BossHealthChangeEvent.kt index e2837ea3fafa..10efc2823f20 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/BossHealthChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/BossHealthChangeEvent.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.events -import at.hannibal2.skyhanni.features.damageindicator.EntityData +import at.hannibal2.skyhanni.features.combat.damageindicator.EntityData class BossHealthChangeEvent(val entityData: EntityData, val lastHealth: Long, val health: Long, val maxHealth: Long) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/DamageIndicatorDetectedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DamageIndicatorDetectedEvent.kt index 2203ab7240c9..dbf2fd130e9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/DamageIndicatorDetectedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/DamageIndicatorDetectedEvent.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.events -import at.hannibal2.skyhanni.features.damageindicator.EntityData +import at.hannibal2.skyhanni.features.combat.damageindicator.EntityData class DamageIndicatorDetectedEvent(val entityData: EntityData) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 32c552221a86..2f39e381dffb 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -1,8 +1,11 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.mixins.transformers.AccessorEventBus import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event +import net.minecraftforge.fml.common.eventhandler.IEventListener abstract class LorenzEvent : Event() { @@ -10,16 +13,42 @@ abstract class LorenzEvent : Event() { this::class.simpleName } - fun postAndCatch(): Boolean { - return runCatching { - postWithoutCatch() - }.onFailure { - ErrorManager.logError( - it, - "Caught an ${it::class.simpleName ?: "error"} at ${eventName}: '${it.message}'" - ) - }.getOrDefault(isCanceled) + fun postAndCatch() = postAndCatchAndBlock {} + + fun postAndCatchAndBlock( + printError: Boolean = true, + stopOnFirstError: Boolean = false, + ignoreErrorCache: Boolean = false, + onError: (Throwable) -> Unit, + ): Boolean { + val visibleErrors = 3 + var errors = 0 + for (listener in getListeners()) { + try { + listener.invoke(this) + } catch (throwable: Throwable) { + errors++ + if (printError && errors <= visibleErrors) { + val callerName = listener.toString().split(" ")[1].split("@")[0].split(".").last() + val errorName = throwable::class.simpleName ?: "error" + val message = "Caught an $errorName at $eventName in $callerName: '${throwable.message}'" + ErrorManager.logError(throwable, message, ignoreErrorCache) + } + onError(throwable) + if (stopOnFirstError) break + } + } + if (errors > visibleErrors) { + val hiddenErrors = errors - visibleErrors + LorenzUtils.chat("§c[SkyHanni] $hiddenErrors more errors in $eventName are hidden!") + } + return if (isCancelable) isCanceled else false + } + + private fun getListeners(): Array { + val accessorEventBus = MinecraftForge.EVENT_BUS as AccessorEventBus + return listenerList.getListeners(accessorEventBus.busId) } fun postWithoutCatch() = MinecraftForge.EVENT_BUS.post(this) -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt index 8010564a07d9..3b2b426fe64b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt @@ -1,22 +1,19 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.data.repo.RepoError +import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.data.repo.RepoUtils -import at.hannibal2.skyhanni.test.command.ErrorManager import com.google.gson.Gson -import com.google.gson.JsonObject import java.io.File import java.lang.reflect.Type class RepositoryReloadEvent(val repoLocation: File, val gson: Gson) : LorenzEvent() { - fun getConstant(constant: String) = getConstant(constant) - inline fun getConstant(constant: String, type: Type? = null) = try { + inline fun getConstant(constant: String, type: Type? = null): T = try { + RepoManager.setlastConstant(constant) + if (!repoLocation.exists()) throw RepoError("Repo folder does not exist!") RepoUtils.getConstant(repoLocation, constant, gson, T::class.java, type) } catch (e: Exception) { - ErrorManager.logError( - Exception("Repo parsing error while trying to read constant '$constant'", e), - "Error reading repo data" - ) - null + throw RepoError("Repo parsing error while trying to read constant '$constant'", e) } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/VisitorAcceptEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/VisitorAcceptEvent.kt deleted file mode 100644 index 620694a22782..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/VisitorAcceptEvent.kt +++ /dev/null @@ -1,5 +0,0 @@ -package at.hannibal2.skyhanni.events - -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures - -class VisitorAcceptEvent(val visitor: GardenVisitorFeatures.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/VisitorArrivalEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/VisitorArrivalEvent.kt deleted file mode 100644 index 91be1bbe58fd..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/VisitorArrivalEvent.kt +++ /dev/null @@ -1,5 +0,0 @@ -package at.hannibal2.skyhanni.events - -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures.Visitor - -class VisitorArrivalEvent(val visitor: Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptEvent.kt new file mode 100644 index 000000000000..4a494f35314f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI + +class VisitorAcceptEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptedEvent.kt new file mode 100644 index 000000000000..e3bffed8b923 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptedEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI + +class VisitorAcceptedEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorArrivalEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorArrivalEvent.kt new file mode 100644 index 000000000000..673f45e201b6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorArrivalEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.Visitor + +class VisitorArrivalEvent(val visitor: Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorLeftEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorLeftEvent.kt new file mode 100644 index 000000000000..f906364ced2b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorLeftEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI + +class VisitorLeftEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorOpenEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorOpenEvent.kt new file mode 100644 index 000000000000..6abec9865725 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorOpenEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI + +class VisitorOpenEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRefusedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRefusedEvent.kt new file mode 100644 index 000000000000..fea24fba9bb8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRefusedEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI + +class VisitorRefusedEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt new file mode 100644 index 000000000000..7cbdc8224fb0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt @@ -0,0 +1,9 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import at.hannibal2.skyhanni.utils.LorenzVec + +class VisitorRenderEvent(val visitor: VisitorAPI.Visitor, val location: LorenzVec, val parent: LorenzRenderWorldEvent) : + LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt new file mode 100644 index 000000000000..1bee8cff6852 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.events.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import net.minecraft.item.ItemStack + +class VisitorToolTipEvent(val visitor: VisitorAPI.Visitor, val itemStack: ItemStack, val toolTip: MutableList) : + LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt index b39809125163..74922ebe4ac9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt @@ -18,7 +18,7 @@ class BazaarOpenPriceWebsite { private var lastClick = SimpleTimeMark.farPast() private val item by lazy { - val neuItem = NEUItems.getItemStack("PAPER", true) + val neuItem = NEUItems.getItemStack("PAPER") Utils.createItemStack( neuItem.item, "§bPrice History", @@ -62,4 +62,4 @@ class BazaarOpenPriceWebsite { } fun isEnabled() = config.openPriceWebsite -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index a2ec3dafc22f..0badd1e57f66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -24,6 +24,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BingoCardDisplay { private var display = emptyList() + // TODO USE SH-REPO private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?.*)".toPattern() init { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt index a112616a32ed..318888fecbe0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt @@ -20,9 +20,7 @@ class BingoCardTips { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant("Bingo")?.let { - tips = it.bingo_tips - } + tips = event.getConstant("Bingo").bingo_tips } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index e7ebc2d9ecd3..9222764b965c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -28,7 +28,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class BingoNextStepHelper { private val config get() = SkyHanniMod.feature.event.bingo.bingoCard private var dirty = true - + // TODO USE SH-REPO private val crystalObtainedPattern = " *§r§e(?Topaz|Sapphire|Jade|Amethyst|Amber) Crystal".toPattern() private val itemIslandRequired = mutableMapOf() private val itemPreconditions = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt index 3e40f0b85488..5f49d40ce91e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt @@ -18,6 +18,7 @@ class CompactBingoChat { private val healthPattern = " §r§7§8\\+§a.* §c❤ Health".toPattern() private val strengthPattern = " §r§7§8\\+§a. §c❁ Strength".toPattern() + // TODO USE SH-REPO @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (!config.enabled) return @@ -125,4 +126,4 @@ class CompactBingoChat { } return false } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index 1470ace28872..0dc99f5952cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -23,6 +23,7 @@ import kotlin.time.Duration.Companion.seconds class MinionCraftHelper { private val config get() = SkyHanniMod.feature.event.bingo + // TODO USE SH-REPO private var minionNamePattern = "(?.*) Minion (?.*)".toPattern() private var display = emptyList() private var hasMinionInInventory = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt index d870197c7c6b..72b28d013da3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt @@ -10,6 +10,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ArachneChatMessageHider { private val config get() = SkyHanniMod.feature.chat private var hideArachneDeadMessage = false + + // TODO USE SH-REPO private val arachneCallingPattern = "§4☄ §r.* §r§eplaced an §r§9Arachne's Calling§r§e!.*".toPattern() private val arachneCrystalPattern = "§4☄ §r.* §r§eplaced an Arachne Crystal! Something is awakening!".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt index 6772e67cf2a5..cf12867f458e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -347,6 +347,8 @@ class ChatFilter { message.matchRegex("§aYou received §r§b\\+\\d{1,3} §r§a(Mithril|Gemstone) Powder.") -> true message == "§6You have successfully picked the lock on this chest!" -> true + message.matchRegex("§aYou received §r(§6|§b)\\+[1-2] (Diamond|Gold) Essence") -> true + else -> false } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt rename to src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt index b92375f10c93..5d5580772eca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatPeek.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GuiEditManager diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt similarity index 97% rename from src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt rename to src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt index 932cdb1bfb03..dfc0db3f95b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index 3296ab782c15..943490a55856 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -17,6 +17,7 @@ class PlayerDeathMessages { private val lastTimePlayerSeen = mutableMapOf() + // TODO USE SH-REPO //§c ☠ §r§7§r§bZeroHazel§r§7 was killed by §r§8§lAshfang§r§7§r§7. private val deathMessagePattern = "§c ☠ §r§7§r§.(?.+)§r§7 (?.+)".toPattern() @@ -61,4 +62,4 @@ class PlayerDeathMessages { private fun isHideFarDeathsEnabled(): Boolean { return LorenzUtils.inSkyBlock && SkyHanniMod.feature.chat.hideFarDeathMessages && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt index af0d1b805e3b..9501b9d49360 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.chat.playerchat import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MultiFilter +import at.hannibal2.skyhanni.utils.jsonobjects.PlayerChatFilterJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PlayerChatFilter { @@ -29,25 +30,16 @@ class PlayerChatFilter { var countCategories = 0 var countFilters = 0 - try { - val data = event.getConstant("PlayerChatFilter") ?: return + val playerChatFilter = event.getConstant("PlayerChatFilter") + for (category in playerChatFilter.filters) { + val description = category.description + val filter = MultiFilter() + filter.load(category) + filters[description] = filter - for (category in data["filters"].asJsonArray) { - val jsonObject = category.asJsonObject - val description = jsonObject["description"].asString - val filter = MultiFilter() - filter.load(jsonObject) - filters[description] = filter - - countCategories++ - countFilters += filter.count() - } - - LorenzUtils.debug("Loaded $countFilters filters in $countCategories categories from repo") - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") + countCategories++ + countFilters += filter.count() } + LorenzUtils.debug("Loaded $countFilters filters in $countCategories categories from repo") } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt similarity index 99% rename from src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 211641694d15..5f0a4125e4dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt similarity index 87% rename from src/main/java/at/hannibal2/skyhanni/features/misc/HideDamageSplash.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt index e2512007c6af..7b2684c40b21 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt @@ -1,8 +1,8 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraftforge.client.event.RenderLivingEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt index 264c8700a132..664aa63d4317 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/BossType.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator enum class BossType( val fullName: String, diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageCounter.kt similarity index 74% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageCounter.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageCounter.kt index bf6bb581b5d4..1595b728a0ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageCounter.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator import java.util.LinkedList diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt similarity index 97% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 689c3d8c503a..4d7ed5593fc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith @@ -21,7 +22,6 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth -import at.hannibal2.skyhanni.utils.LorenzUtils.between import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.LorenzUtils.put import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.getLorenzVec @@ -55,6 +56,8 @@ class DamageIndicatorManager { private val maxHealth = mutableMapOf() private val config get() = SkyHanniMod.feature.combat.damageIndicator + private val enderSlayerHitsNumberPattern = ".* §[5fd]§l(?\\d+) Hits?".toPattern() + companion object { private var data = mapOf() private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() @@ -162,8 +165,8 @@ class DamageIndicatorManager { var healthText = data.healthText val delayedStart = data.delayedStart if (delayedStart != -1L && delayedStart > System.currentTimeMillis()) { - val delay = delayedStart - System.currentTimeMillis() - healthText = formatDelay(delay) + val delay = delayedStart - System.currentTimeMillis() + healthText = formatDelay(delay) } val location = if (data.dead && data.deathLocation != null) { @@ -356,7 +359,7 @@ class DamageIndicatorManager { entityData.timeLastTick = System.currentTimeMillis() return entity.uniqueID to entityData } catch (e: Throwable) { - e.printStackTrace() + ErrorManager.logError(e, "Error checking damage indicator entity $entity") return null } } @@ -615,7 +618,6 @@ class DamageIndicatorManager { entityData.namePrefix = "" } - //Hit phase val armorStandHits = entity.getNameTagWith(3, " Hit") if (armorStandHits != null) { @@ -626,15 +628,9 @@ class DamageIndicatorManager { BossType.SLAYER_ENDERMAN_4 -> 100 else -> 100 } - val name = armorStandHits.name.removeColor() - - // TODO replace this super ugly workaround with regex - val text = name.between("Seraph ", " Hit") - val hits = try { - text.toInt() - } catch (e: NumberFormatException) { - text.substring(2).toInt() - } + val hits = enderSlayerHitsNumberPattern.matchMatcher(armorStandHits.name) { + group("hits").toInt() + } ?: error("No hits number found in ender slayer name '${armorStandHits.name}'") return NumberUtil.percentageColor(hits.toLong(), maxHits.toLong()).getChatColor() + "$hits Hits" } @@ -779,7 +775,6 @@ class DamageIndicatorManager { private fun grabData(entity: EntityLivingBase): EntityData? { if (data.contains(entity.uniqueID)) return data[entity.uniqueID] - val entityResult = mobFinder?.tryAdd(entity) ?: return null val entityData = EntityData( @@ -859,4 +854,4 @@ class DamageIndicatorManager { } fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt similarity index 93% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt index 7055b7df40d5..970bdd0dd893 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityData.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.TimeUnit diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityResult.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt similarity index 76% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityResult.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt index a17adf3095ed..4f692029337f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/EntityResult.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/EntityResult.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator class EntityResult( val delayedStart: Long = -1L, diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt similarity index 99% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt index 2bb65b942c96..3472e26be768 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/MobFinder.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.features.dungeon.DungeonAPI @@ -151,7 +151,7 @@ class MobFinder { ) } - if (DungeonAPI.isOneOf("F5", "M5") && entity is EntityOtherPlayerMP && entity == DungeonLividFinder.livid) { + if (DungeonAPI.isOneOf("F5", "M5") && entity is EntityOtherPlayerMP && entity == DungeonLividFinder.lividEntity) { return EntityResult( bossType = BossType.DUNGEON_F5, ignoreBlocks = true, @@ -459,7 +459,7 @@ class MobFinder { //F5 "§c[BOSS] Livid§r§f: This Orb you see, is Thorn, or what is left of him." -> { - floor5lividEntity = DungeonLividFinder.livid + floor5lividEntity = DungeonLividFinder.lividEntity floor5lividEntitySpawnTime = System.currentTimeMillis() + 13_000 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/OldDamage.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/OldDamage.kt similarity index 52% rename from src/main/java/at/hannibal2/skyhanni/features/damageindicator/OldDamage.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/OldDamage.kt index 26c0a751ab4c..77ca2c6c9ee4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/OldDamage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/OldDamage.kt @@ -1,3 +1,3 @@ -package at.hannibal2.skyhanni.features.damageindicator +package at.hannibal2.skyhanni.features.combat.damageindicator class OldDamage(val time: Long, val damage: Long, val healing: Long) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNode.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNode.kt index 301dc65e2e45..bdfb97833e46 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNode.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.combat.endernodetracker import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt similarity index 99% rename from src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index d07ae0ef2ea6..7fb000766b65 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.combat.endernodetracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index 8c228772097e..959a303e8bb3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.ghostcounter +package at.hannibal2.skyhanni.features.combat.ghostcounter import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator @@ -15,14 +15,14 @@ import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.Option -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.Option.KILLS -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.bestiaryData -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.formatBestiary -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.formatText -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.isUsingCTGhostCounter -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.preFormat -import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.prettyTime +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option.KILLS +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.bestiaryData +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatBestiary +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatText +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.isUsingCTGhostCounter +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.preFormat +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.prettyTime import at.hannibal2.skyhanni.utils.CombatUtils._isKilling import at.hannibal2.skyhanni.utils.CombatUtils.calculateETA import at.hannibal2.skyhanni.utils.CombatUtils.calculateXP @@ -455,7 +455,7 @@ object GhostCounter { val inventoryName = event.inventoryName if (inventoryName != "Bestiary ➜ Dwarven Mines") return val stacks = event.inventoryItems - val ghostStack = stacks[10] ?: return + val ghostStack = stacks.values.find { it.displayName.contains("Ghost") } ?: return val bestiaryNextLevel = if ("§\\wGhost".toRegex().matches(ghostStack.displayName)) 1 else ghostStack.displayName.substring(8) .romanToDecimal() + 1 @@ -491,4 +491,4 @@ object GhostCounter { fun isEnabled(): Boolean { return LorenzUtils.inSkyBlock && config.enabled && LorenzUtils.skyBlockIsland == IslandType.DWARVEN_MINES } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt index e56e0a7fffbb..70832980c4dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.ghostcounter +package at.hannibal2.skyhanni.features.combat.ghostcounter import java.util.regex.Pattern import kotlin.math.roundToInt diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostFormatting.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt similarity index 99% rename from src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostFormatting.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt index 1aee5584917f..70f64de296c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostFormatting.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.ghostcounter +package at.hannibal2.skyhanni.features.combat.ghostcounter import com.google.gson.JsonArray import com.google.gson.JsonParser diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt similarity index 99% rename from src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt index 82acce71b450..6dffc62fcbc8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.ghostcounter +package at.hannibal2.skyhanni.features.combat.ghostcounter import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt index d603d97d63bb..e63119a116a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/AreaMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mobs +package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/AshfangMinisNametagHider.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt similarity index 94% rename from src/main/java/at/hannibal2/skyhanni/features/mobs/AshfangMinisNametagHider.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt index 87d4e5a1357a..657e13d737db 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/AshfangMinisNametagHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mobs +package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.LorenzUtils diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt index b0b7fc3cacc1..c3df8091d9c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mobs +package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt index 24a720508a5e..966f8ad064ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mobs/SpawnTimers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.mobs +package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt new file mode 100644 index 000000000000..f57738f1fd74 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt @@ -0,0 +1,83 @@ +package at.hannibal2.skyhanni.features.commands + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.FriendAPI +import at.hannibal2.skyhanni.data.PartyAPI +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object PartyCommands { + private val config get() = SkyHanniMod.feature.commands + + fun kickOffline() { + if (!config.shortCommands) return + if (PartyAPI.partyMembers.isEmpty()) return + LorenzUtils.sendCommandToServer("party kickoffline") + } + + fun warp() { + if (!config.shortCommands) return + if (PartyAPI.partyMembers.isEmpty()) return + LorenzUtils.sendCommandToServer("party warp") + } + + fun kick(args: Array) { + if (!config.shortCommands) return + if (PartyAPI.partyMembers.isEmpty()) return + if (args.isEmpty()) return + LorenzUtils.sendCommandToServer("party kick ${args[0]}") + } + + fun transfer(args: Array) { + if (args.isEmpty()) LorenzUtils.sendCommandToServer("pt") + if (!config.shortCommands) return + if (PartyAPI.partyMembers.isEmpty()) return + LorenzUtils.sendCommandToServer("party transfer ${args[0]}") + } + + fun promote(args: Array) { + if (!config.shortCommands) return + if (PartyAPI.partyMembers.isEmpty()) return + if (args.isEmpty()) return + LorenzUtils.sendCommandToServer("party promote ${args[0]}") + } + + fun customTabComplete(command: String): List? { + if (command == "pk" || command == "pt" || command == "pp" && config.shortCommands) { + return PartyAPI.partyMembers + } + + if (command == "p" || command == "party") { + val friends = if (config.tabComplete.friends) { + FriendAPI.getAllFriends().filter { it.bestFriend || config.tabComplete.onlyBestFriends }.map { it.name } + } else { + emptyList() + } + return friends + getPartyCommands() + } + return null + } + + private fun getPartyCommands(): List { + return if (config.tabComplete.partyCommands && PartyAPI.partyMembers.isNotEmpty()) { + otherPartyCommands + } else emptyList() + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(5, "commands.usePartyTransferAlias", "commands.shortCommands") + } +} + +private val otherPartyCommands = listOf( + "Disband", + "KickOffline", + "Leave", + "List", + "Mute", + "Private", + "Warp", + "Settings" +) diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyTransferCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyTransferCommand.kt deleted file mode 100644 index 485a3569f6de..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyTransferCommand.kt +++ /dev/null @@ -1,26 +0,0 @@ -package at.hannibal2.skyhanni.features.commands - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.PacketEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import net.minecraft.network.play.client.C01PacketChatMessage -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class PartyTransferCommand { - @SubscribeEvent - fun onSendPacket(event: PacketEvent.SendEvent) { - if (!SkyHanniMod.feature.commands.usePartyTransferAlias) return - - val packet = event.packet - if (packet is C01PacketChatMessage) { - val pattern = "/pt (?.*)".toPattern() - pattern.matchMatcher(packet.message.lowercase()) { - event.isCanceled = true - val args = group("args") - LorenzUtils.sendCommandToServer("party transfer $args") - } - } - } - -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt new file mode 100644 index 000000000000..4464959e25dc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.features.commands + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems +import net.minecraft.network.play.client.C01PacketChatMessage +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object ViewRecipeCommand { + private val config get() = SkyHanniMod.feature.commands + + @SubscribeEvent + fun onSendPacket(event: PacketEvent.SendEvent) { + if (!config.viewRecipeLowerCase) return + val packet = event.packet + if (packet is C01PacketChatMessage) { + val message = packet.message + if (message == message.uppercase()) return + if (message.startsWith("/viewrecipe ", ignoreCase = true)) { + event.isCanceled = true + LorenzUtils.sendMessageToServer(message.uppercase()) + } + } + } + + val list by lazy { + val list = mutableListOf() + for ((key, value) in NEUItems.manager.itemInformation) { + if (value.has("recipe")) { + list.add(key.lowercase()) + } + } + list + } + + fun customTabComplete(command: String): List? { + if (command == "viewrecipe" && config.tabComplete.viewrecipeItems) { + return list + } + + return null + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt deleted file mode 100644 index 4976c4d9fae0..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiCommand.kt +++ /dev/null @@ -1,34 +0,0 @@ -package at.hannibal2.skyhanni.features.commands - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.PacketEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.OSUtils -import net.minecraft.network.play.client.C01PacketChatMessage -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class WikiCommand { - - @SubscribeEvent - fun onSendPacket(event: PacketEvent.SendEvent) { - val packet = event.packet - - if (!SkyHanniMod.feature.commands.useFandomWiki) return - - if (packet is C01PacketChatMessage) { - val message = packet.message.lowercase() - if (message == "/wiki") { - event.isCanceled = true - OSUtils.openBrowser("https://hypixel-skyblock.fandom.com/wiki/Hypixel_SkyBlock_Wiki") - LorenzUtils.chat("§e[SkyHanni] Opening the Fandom Wiki..") - } else if (message.startsWith("/wiki ")) { - event.isCanceled = true - val search = packet.message.substring(6) - LorenzUtils.chat("§e[SkyHanni] Searching the Fandom Wiki for §c$search") - - val url = "https://www.google.com/search?q=inurl%3Ahypixel-skyblock.fandom.com $search&hl=en" - OSUtils.openBrowser(url.replace(' ', '+')) - } - } - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt new file mode 100644 index 000000000000..c515cb7f080c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt @@ -0,0 +1,83 @@ +package at.hannibal2.skyhanni.features.commands + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment +import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.item.ItemStack +import net.minecraft.network.play.client.C01PacketChatMessage +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class WikiManager { + + private val config get() = SkyHanniMod.feature.commands.fandomWiki + + companion object { + private val urlPrefix = "https://hypixel-skyblock.fandom.com/wiki/" + val urlSearchPrefix = "${urlPrefix}Special:Search?query=" + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(6, "commands.useFandomWiki", "commands.fandomWiki.enabled") + } + + @SubscribeEvent + fun onSendPacket(event: PacketEvent.SendEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!isEnabled()) return + + val packet = event.packet + + if (packet is C01PacketChatMessage) { + val message = packet.message.lowercase() + if (!(message.startsWith("/wiki"))) return + event.isCanceled = true + if (message == "/wiki") { + LorenzUtils.chat("§e[SkyHanni] Opening the Fandom Wiki..") + OSUtils.openBrowser("${urlPrefix}Hypixel_SkyBlock_Wiki") + } else if (message.startsWith("/wiki ") || message == ("/wikithis")) { //conditional to see if we need Special:Search page + if (message == ("/wikithis")) { + val itemInHand = InventoryUtils.getItemInHand() ?: return + wikiTheItem(itemInHand) + } else { + val search = packet.message.split("/wiki ").last() + LorenzUtils.chat("§e[SkyHanni] Searching the Fandom Wiki for §a$search") + val wikiUrlCustom = "$urlSearchPrefix$search&scope=internal" + OSUtils.openBrowser(wikiUrlCustom.replace(' ', '+')) + } + } + } + } + + @SubscribeEvent + fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { + if (!LorenzUtils.inSkyBlock) return + val gui = event.gui as? GuiContainer ?: return + if (NEUItems.neuHasFocus()) return //because good heavens if this worked on neuitems... + val stack = gui.slotUnderMouse?.stack ?: return + + if (!config.fandomWikiKeybind.isKeyHeld()) return + wikiTheItem(stack) + } + + private fun wikiTheItem(item: ItemStack) { + val itemDisplayName = (item.nameWithEnchantment ?: return).replace("§a✔ ", "").replace("§c✖ ", "") + val internalName = item.getInternalName().asString() + LorenzUtils.chat("§e[SkyHanni] Searching the Fandom Wiki for §a$itemDisplayName") + val wikiUrlSearch = if (internalName != "NONE") "$urlSearchPrefix$internalName&scope=internal" + else "$urlSearchPrefix${itemDisplayName.removeColor()}&scope=internal" + OSUtils.openBrowser(wikiUrlSearch.replace(' ', '+')) + } + + private fun isEnabled() = config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/GetFromSacksTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt similarity index 88% rename from src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/GetFromSacksTabComplete.kt rename to src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt index 50d1724e5740..97a110508c2c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/GetFromSacksTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt @@ -1,10 +1,10 @@ -package at.hannibal2.skyhanni.features.misc.tabcomplete +package at.hannibal2.skyhanni.features.commands.tabcomplete import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.jsonobjects.SackListJson +import at.hannibal2.skyhanni.utils.jsonobjects.SacksJson import net.minecraft.network.play.client.C01PacketChatMessage import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -15,7 +15,7 @@ object GetFromSacksTabComplete { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - sackList = event.getConstant("Sacks")?.sackList ?: return + sackList = event.getConstant("Sacks").sackList } fun handleTabComplete(command: String): List? { @@ -42,4 +42,4 @@ object GetFromSacksTabComplete { } fun isEnabled() = LorenzUtils.inSkyBlock && config.gfsSack -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt similarity index 79% rename from src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt rename to src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt index 28c9733a4dbc..e6b2baaf8c16 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.tabcomplete +package at.hannibal2.skyhanni.features.commands.tabcomplete import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator @@ -13,11 +13,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object PlayerTabComplete { private val config get() = SkyHanniMod.feature.commands.tabComplete - private var vipVisitsJson: VipVisitsJson? = null + private var vipVisits = listOf() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - vipVisitsJson = event.getConstant("VipVisits") + val data = event.getConstant("VipVisits") + vipVisits = data.vipVisits } @SubscribeEvent @@ -26,16 +27,12 @@ object PlayerTabComplete { } enum class PlayerCategory { - PARTY, FRIENDS, ISLAND_PLAYERS, } fun handleTabComplete(command: String): List? { val commands = mapOf( - "p" to listOf(PlayerCategory.PARTY), - "party" to listOf(PlayerCategory.PARTY), - "pt" to listOf(PlayerCategory.FRIENDS, PlayerCategory.ISLAND_PLAYERS), // /party transfer "f" to listOf(PlayerCategory.FRIENDS), "friend" to listOf(PlayerCategory.FRIENDS), @@ -68,19 +65,17 @@ object PlayerTabComplete { } } - if (config.party && PlayerCategory.PARTY !in ignored) { + if (config.party) { for (member in PartyAPI.partyMembers) { add(member) } } if (config.vipVisits && command == "visit") { - vipVisitsJson?.let { - for (visit in it.vipVisits) { - add(visit) - } + for (visit in vipVisits) { + add(visit) } } } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt similarity index 79% rename from src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt rename to src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt index b003de699579..a835efd38d50 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt @@ -1,5 +1,7 @@ -package at.hannibal2.skyhanni.features.misc.tabcomplete +package at.hannibal2.skyhanni.features.commands.tabcomplete +import at.hannibal2.skyhanni.features.commands.PartyCommands +import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand import at.hannibal2.skyhanni.features.misc.CollectionTracker object TabComplete { @@ -24,6 +26,8 @@ object TabComplete { WarpTabComplete.handleTabComplete(command)?.let { return it } PlayerTabComplete.handleTabComplete(command)?.let { return it } CollectionTracker.handleTabComplete(command)?.let { return it } + PartyCommands.customTabComplete(command)?.let { return it } + ViewRecipeCommand.customTabComplete(command)?.let { return it } return null } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/WarpTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt similarity index 75% rename from src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/WarpTabComplete.kt rename to src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt index 034ea12dc2c7..ea76e03eaf07 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/WarpTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.tabcomplete +package at.hannibal2.skyhanni.features.commands.tabcomplete import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RepositoryReloadEvent @@ -8,19 +8,20 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object WarpTabComplete { private val config get() = SkyHanniMod.feature.commands.tabComplete - private var warpsJson: WarpsJson? = null + private var warps = listOf() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - warpsJson = event.getConstant("Warps") + val data = event.getConstant("Warps") + warps = data.warpCommands } fun handleTabComplete(command: String): List? { if (!isEnabled()) return null if (command != "warp") return null - return warpsJson?.warpCommands + return warps } fun isEnabled() = LorenzUtils.inSkyBlock && config.warps -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt new file mode 100644 index 000000000000..f7a28d78d4af --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt @@ -0,0 +1,74 @@ +package at.hannibal2.skyhanni.features.cosmetics + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.getPrevLorenzVec +import net.minecraft.client.Minecraft +import net.minecraft.entity.projectile.EntityArrow +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.LinkedList +import kotlin.time.DurationUnit +import kotlin.time.toDuration + +class ArrowTrail { + + private val config get() = SkyHanniMod.feature.misc.cosmeticConfig.arrowTrailConfig + + private data class Line(val start: LorenzVec, val end: LorenzVec, val deathTime: SimpleTimeMark) + + private val listAllArrow: MutableList = LinkedList() + private val listYourArrow: MutableList = LinkedList() + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + val secondsAlive = config.secondsAlive.toDouble().toDuration(DurationUnit.SECONDS) + val time = SimpleTimeMark.now() + val deathTime = time.plus(secondsAlive) + if (event.isMod(2)) { + listAllArrow.removeIf { it.deathTime.isInPast() } + listYourArrow.removeIf { it.deathTime.isInPast() } + } + EntityUtils.getEntities().forEach { + val line = Line(it.getPrevLorenzVec(), it.getLorenzVec(), deathTime) + if (it.shootingEntity == Minecraft.getMinecraft().thePlayer) { + listYourArrow.add(line) + } else { + listAllArrow.add(line) + } + } + } + + @SubscribeEvent + fun onWorldRender(event: LorenzRenderWorldEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled) return + val color = if (config.handlePlayerArrowsDifferently) config.playerArrowColor else config.arrowColor + val playerArrowColor = color.toChromaColor() + listYourArrow.forEach { + event.draw3DLine(it.start, it.end, playerArrowColor, config.lineWidth, true) + } + if (!config.hideOtherArrows) { + val arrowColor = config.arrowColor.toChromaColor() + listAllArrow.forEach { + event.draw3DLine(it.start, it.end, arrowColor, config.lineWidth, true) + } + } + } + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + listAllArrow.clear() + listYourArrow.clear() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt index c14e717a53b3..a298aff40c7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraftforge.client.event.RenderLivingEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt index d10122334266..701ef74eebb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -71,7 +71,7 @@ class DungeonCleanEnd { if (lastBossId == -1) return if (event.entity.entityId != lastBossId) return - if (event.health <= 0) { + if (event.health <= 0.5) { val dungeonFloor = DungeonAPI.dungeonFloor LorenzUtils.chat("§eFloor $dungeonFloor done!") bossDone = true @@ -121,4 +121,4 @@ class DungeonCleanEnd { event.move(3, "dungeon.cleanEndF3IgnoreGuardians", "dungeon.cleanEnd.F3IgnoreGuardians") } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt new file mode 100644 index 000000000000..eceb28ad16f7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt @@ -0,0 +1,176 @@ +package at.hannibal2.skyhanni.features.dungeon + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class DungeonFinderFeatures { + private val config get() = SkyHanniMod.feature.dungeon.partyFinder + + private val pricePattern = "([0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?mil)".toRegex(RegexOption.IGNORE_CASE) + private val carryPattern = "(carry|cary|carries|caries|comp|to cata [0-9]{2})".toRegex(RegexOption.IGNORE_CASE) + private val memberPattern = "^ §.*?§.: §.([A-Z]+)§. \\(§.([0-9]+)§.\\)".toRegex(RegexOption.IGNORE_CASE) + private val ineligiblePattern = "^§c(Requires .*$|You don't meet the requirement!|Complete previous floor first!$)".toRegex() + private val classLevelPattern = " §.(?.*)§f: §e(?.*)§b \\(§e(?.*)§b\\)".toPattern() + private val notePattern = "^(§7§7Note: |§f[^§])".toRegex() + + private var selectedClass = "" + + @SubscribeEvent + fun onRenderItemTip(event: RenderItemTipEvent) { + if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return + if (!config.floorAsStackSize) return + + val itemName = event.stack.name?.removeColor() ?: "" + val invName = InventoryUtils.openInventoryName() + + if (invName == "Select Floor") { + if (itemName == "Any") { + event.stackTip = "A" + } else if (itemName == "Entrance") { + event.stackTip = "E" + } else if (itemName.startsWith("Floor ")) { + event.stackTip = itemName.split(' ').last().romanToDecimalIfNeeded().toString() + } + } else if (itemName.startsWith("The Catacombs - ") || itemName.startsWith("MM Catacombs -")) { + val floor = itemName.split(" - ").last().removeColor() + val floorNum = floor.split(' ').last().romanToDecimalIfNeeded().toString() + val isMasterMode = itemName.contains("MM ") + + event.stackTip = if (floor.contains("Entrance")) { + "E" + } else if (isMasterMode) { + "M${floorNum}" + } else { + "F${floorNum}" + } + } else if (itemName.endsWith("'s Party")) { + val floor = event.stack.getLore().find { it.startsWith("§7Floor: ") } ?: return + val dungeon = event.stack.getLore().find { it.startsWith("§7Dungeon: ") } ?: return + val floorNum = floor.split(' ').last().romanToDecimalIfNeeded().toString() + val isMasterMode = dungeon.contains("Master Mode") + + event.stackTip = if (floor.contains("Entrance")) { + "E" + } else if (isMasterMode) { + "M${floorNum}" + } else { + "F${floorNum}" + } + } + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return + if (event.inventoryName != "Catacombs Gate") return + + val lore = event.inventoryItems[45]?.getLore() ?: return + + if (lore[0] == "§7View and select a dungeon class.") { + selectedClass = lore[2].split(" ").last().removeColor() + } + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return + if (event.gui !is GuiChest) return + + val chest = event.gui.inventorySlots as ContainerChest + val inventoryName = chest.getInventoryName() + if (inventoryName != "Party Finder") return + + for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + if (slot.stack == null) continue + + val itemName = slot.stack.name ?: continue + if (!itemName.endsWith(" Party")) continue + + if (config.markIneligibleGroups && slot.stack.getLore().any { ineligiblePattern.matches(it) }) { + slot highlight LorenzColor.DARK_RED + continue + } + + if (config.markPaidCarries) { + val note = slot.stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ") ?: "" + + if (pricePattern.containsMatchIn(note) && carryPattern.containsMatchIn(note)) { + slot highlight LorenzColor.RED + continue + } + } + + val members = slot.stack.getLore().filter { memberPattern.matches(it) } + val memberLevels = members.map { memberPattern.matchEntire(it)?.groupValues?.get(2)?.toInt() ?: 0 } + val memberClasses = members.map { memberPattern.matchEntire(it)?.groupValues?.get(1) ?: "" } + + if (memberLevels.any { it <= config.markBelowClassLevel }) { + slot highlight LorenzColor.YELLOW + continue + } + + if (config.markMissingClass && memberClasses.none { it == selectedClass }) { + slot highlight LorenzColor.GREEN + } + } + } + + @SubscribeEvent + fun onItemTooltip(event: ItemTooltipEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.coloredClassLevel) return + + if (event.toolTip == null) return + val chestName = InventoryUtils.openInventoryName() + if (chestName != "Party Finder") return + + val stack = event.itemStack + + for ((index, line) in stack.getLore().withIndex()) { + classLevelPattern.matchMatcher(line) { + val playerName = group("playerName") + val className = group("className") + val level = group("level").toInt() + val color = getColor(level) + event.toolTip[index + 1] = " §b$playerName§f: §e$className $color$level" + } + } + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "dungeon.partyFinderColoredClassLevel", "dungeon.partyFinder.coloredClassLevel") + } + +} + +fun getColor(level: Int): String { + if (level >= 50) return "§c§l" + if (level >= 45) return "§c" + if (level >= 40) return "§d" + if (level >= 35) return "§6" + if (level >= 30) return "§5" + if (level >= 25) return "§9" + if (level >= 20) return "§a" + if (level >= 10) return "§f" + return "§7" +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt deleted file mode 100644 index b15cdabb71bc..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt +++ /dev/null @@ -1,55 +0,0 @@ -package at.hannibal2.skyhanni.features.dungeon - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class DungeonLevelColor { - private val pattern = " §.(?.*)§f: §e(?.*)§b \\(§e(?.*)§b\\)".toPattern() - - @SubscribeEvent - fun onItemTooltip(event: ItemTooltipEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.dungeon.partyFinder.coloredClassLevel) return - - if (event.toolTip == null) return - val chestName = InventoryUtils.openInventoryName() - if (chestName != "Party Finder") return - - val stack = event.itemStack - var index = 0 - for (line in stack.getLore()) { - index++ - - pattern.matchMatcher(line) { - val playerName = group("playerName") - val className = group("className") - val level = group("level").toInt() - val color = getColor(level) - event.toolTip[index] = " §b$playerName§f: §e$className $color$level" - } - } - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(3, "dungeon.partyFinderColoredClassLevel", "dungeon.partyFinder.coloredClassLevel") - } -} - -fun getColor(level: Int): String { - if (level >= 50) return "§c§l" - if (level >= 45) return "§c" - if (level >= 40) return "§d" - if (level >= 35) return "§6" - if (level >= 30) return "§5" - if (level >= 25) return "§9" - if (level >= 20) return "§a" - if (level >= 10) return "§f" - return "§7" -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index 39c1373cba95..48a0a99258f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -1,46 +1,66 @@ package at.hannibal2.skyhanni.features.dungeon +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer +import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.block.BlockStainedGlass import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.item.EntityArmorStand import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color object DungeonLividFinder { - var livid: EntityOtherPlayerMP? = null - private var gotBlinded = false + private val config get() = SkyHanniMod.feature.dungeon.lividFinder private val blockLocation = LorenzVec(6, 109, 43) - private val lividColor = Color(191, 0, 255).rgb + + var lividEntity: EntityOtherPlayerMP? = null + private var lividArmorStand: EntityArmorStand? = null + private var gotBlinded = false + private var color: LorenzColor? = null @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (!LorenzUtils.inDungeons || !DungeonAPI.inBossRoom) return - if (DungeonAPI.dungeonFloor != "F5" && DungeonAPI.dungeonFloor != "M5") return - if (DungeonAPI.dungeonFloor == "F5" && livid != null) return - if (!event.repeatSeconds(2)) return + if (!inDungeon()) return + if (!event.isMod(2)) return + + val isCurrentlyBlind = isCurrentlyBlind() if (!gotBlinded) { - gotBlinded = Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) + gotBlinded = isCurrentlyBlind return - } else if (Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness)) return + } else if (isCurrentlyBlind) return + + if (!config.enabled) return val dyeColor = blockLocation.getBlockStateAt().getValue(BlockStainedGlass.COLOR) - val chatColor = dyeColor.toLorenzColor()?.getChatColor() ?: return + color = dyeColor.toLorenzColor() ?: error("No color found for dye color `$dyeColor`") + + val color = color ?: return + val chatColor = color.getChatColor() - val lividEntity = EntityUtils.getEntities() - .firstOrNull { it.name.startsWith("${chatColor}﴾ ${chatColor}§lLivid") } ?: return + lividArmorStand = EntityUtils.getEntities() + .firstOrNull { it.name.startsWith("${chatColor}﴾ ${chatColor}§lLivid") } + val lividArmorStand = lividArmorStand ?: return - val aabb = with(lividEntity) { + val aabb = with(lividArmorStand) { AxisAlignedBB( posX - 0.5, posY - 2, @@ -51,17 +71,72 @@ object DungeonLividFinder { ) } val world = Minecraft.getMinecraft().theWorld - livid = world.getEntitiesWithinAABB(EntityOtherPlayerMP::class.java, aabb) + val newLivid = world.getEntitiesWithinAABB(EntityOtherPlayerMP::class.java, aabb) .takeIf { it.size == 1 }?.firstOrNull() ?: return - livid?.let { - RenderLivingEntityHelper.setEntityColor(it, lividColor) { true } - LorenzUtils.debug("Livid found!") + if (!newLivid.name.contains("Livid")) return + + lividEntity = newLivid + RenderLivingEntityHelper.setEntityColor(newLivid, color.toColor().withAlpha(30)) { shouldHighlight() } + RenderLivingEntityHelper.setNoHurtTime(newLivid) { shouldHighlight() } + } + + fun shouldHighlight() = getLividAlive() != null && config.enabled + + private fun getLividAlive() = lividEntity?.let { + if (!it.isDead && it.health > 0.5) it else null + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!inDungeon()) return + if (!config.hideWrong) return + if (!config.enabled) return + + val entity = event.entity + if (entity is EntityPlayerSP) return + val livid = getLividAlive() ?: return + + if (entity != livid && entity != lividArmorStand) { + if (entity.name.contains("Livid")) { + event.isCanceled = true + } } } + private fun isCurrentlyBlind() = if (Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness)) { + Minecraft.getMinecraft().thePlayer.getActivePotionEffect(Potion.blindness).duration > 10 + } else false + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!inDungeon()) return + if (!config.enabled) return + + val livid = getLividAlive() ?: return + val location = livid.getLorenzVec().add(-0.5, 0.0, -0.5) + + val lorenzColor = color ?: return + + event.drawDynamicText(location, lorenzColor.getChatColor() + "Livid", 1.5) + + if (location.distanceSqToPlayer() < 50) return + + val color = lorenzColor.toColor() + event.draw3DLine(event.exactPlayerEyeLocation(), location.add(0.5, 0.0, 0.5), color, 3, true) + event.drawWaypointFilled(location, color, beacon = false, seeThroughBlocks = true) + } + @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - livid = null + lividEntity = null gotBlinded = false } -} \ No newline at end of file + + fun inDungeon(): Boolean { + if (!LorenzUtils.inDungeons) return false + if (!DungeonAPI.inBossRoom) return false + if (!DungeonAPI.isOneOf("F5", "M5")) return false + + return true + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt index 99795274cd37..28cc33e1b3f1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt @@ -6,9 +6,13 @@ import at.hannibal2.skyhanni.data.MayorElection import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName object DianaAPI { - fun hasSpadeInHand() = InventoryUtils.itemInHandId.equals("ANCESTRAL_SPADE") + + val spade by lazy { "ANCESTRAL_SPADE".asInternalName() } + + fun hasSpadeInHand() = InventoryUtils.itemInHandId == spade private fun isRitualActive() = MayorElection.isPerkActive("Diana", "Mythological Ritual") || MayorElection.isPerkActive("Jerry", "Perkpocalypse") || SkyHanniMod.feature.event.diana.alwaysDiana diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index dcc0e9593de8..486a19d805b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.init.Blocks @@ -129,8 +129,7 @@ class GriffinBurrowParticleFinder { } } - private val ItemStack.isSpade - get() = getInternalName_old() == "ANCESTRAL_SPADE" + private val ItemStack.isSpade get() = getInternalName() == DianaAPI.spade class Burrow( var location: LorenzVec, diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index b2de6cee7fe8..ae8b1a892165 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -29,10 +29,11 @@ import kotlin.time.Duration.Companion.seconds object InquisitorWaypointShare { private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing + + // TODO USE SH-REPO private val partyPattern = "§9Party §8> (?.*)§f: §rx: (?-?[0-9]{1,4}), y: (?-?[0-9]{1,4}), z: (?-?[0-9]{1,4})\\b".toPattern() private val diedPattern = "§9Party §8> (?.*)§f: §rInquisitor dead!".toPattern() - private var time = 0L private var testTime = 0L private var lastInquisitorMessage = "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt similarity index 92% rename from src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt rename to src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt index e2c70cedc06f..e4670ffccf57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasure.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.event.jerry.frozentreasure enum class FrozenTreasure( val internalName: String, diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt similarity index 98% rename from src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt rename to src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt index 21e28319de54..034761654899 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc +package at.hannibal2.skyhanni.features.event.jerry.frozentreasure import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index 1238f41dfd5d..0d6f1cd752f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -34,6 +34,8 @@ class CityProjectFeatures { private var display = emptyList>() private var inInventory = false private var lastReminderSend = 0L + + // TODO USE SH-REPO private val contributeAgainPattern = "§7Contribute again: §e(?