From 12135902c08c1926f76f88be4052cdf1ae20194d Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 31 Oct 2023 01:56:03 +0100 Subject: Add visitor highlighter/blocker --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/features/GardenConfig.java | 460 +++++++++++---------- .../visitor/HighlightVisitorsOutsideOfGarden.kt | 101 +++++ .../test/command/CopyNearbyEntitiesCommand.kt | 3 +- .../skyhanni/utils/jsonobjects/GardenJson.java | 21 +- 5 files changed, 372 insertions(+), 215 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 326f5798f..c7d3bb9fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -159,6 +159,7 @@ 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.HighlightVisitorsOutsideOfGarden import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter import at.hannibal2.skyhanni.features.inventory.ChestValue @@ -353,6 +354,7 @@ class SkyHanniMod { loadModule(VisitorListener()) loadModule(OwnInventoryData()) loadModule(ToolTipData()) + loadModule(HighlightVisitorsOutsideOfGarden()) loadModule(GuiEditManager()) loadModule(UpdateManager) loadModule(CropAccessoryData()) 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 d550d3f72..8829b564f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -60,14 +60,14 @@ public class GardenConfig { public static class TimerConfig { @Expose @ConfigOption(name = "Visitor Timer", desc = "Timer when the next visitor will appear, " + - "and a number for how many visitors are already waiting.") + "and a number for how many visitors are already waiting.") @ConfigEditorBoolean @FeatureToggle public boolean enabled = true; @Expose @ConfigOption(name = "Sixth Visitor Estimate", desc = "Estimate when the sixth visitor in the queue will arrive. " + - "May be inaccurate with co-op members farming simultaneously.") + "May be inaccurate with co-op members farming simultaneously.") @ConfigEditorBoolean public boolean sixthVisitorEnabled = true; @@ -109,7 +109,7 @@ public class GardenConfig { @Expose @ConfigOption(name = "Bazaar Alley", desc = "Show the Visitor Items List while inside the Bazaar Alley in the Hub. " + - "This helps buying the correct amount when not having a Booster Cookie Buff active.") + "This helps buying the correct amount when not having a Booster Cookie Buff active.") @ConfigEditorBoolean public boolean inBazaarAlley = true; @@ -197,20 +197,20 @@ public class GardenConfig { */ @Expose @ConfigOption( - name = "Items", - desc = "Warn for these reward items." + name = "Items", + desc = "Warn for these reward items." ) @ConfigEditorDraggableList( - exampleText = { - "§9Flowering Bouquet", - "§9Overgrown Grass", - "§9Green Bandana", - "§9Dedication IV", - "§9Music Rune", - "§cSpace Helmet", - "§9Cultivating I", - "§9Replenish I", - } + exampleText = { + "§9Flowering Bouquet", + "§9Overgrown Grass", + "§9Green Bandana", + "§9Dedication IV", + "§9Music Rune", + "§cSpace Helmet", + "§9Cultivating I", + "§9Replenish I", + } ) public List drops = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)); } @@ -259,8 +259,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Enabled", - desc = "Tallies up statistic about visitors and the rewards you have received from them." + name = "Enabled", + desc = "Tallies up statistic about visitors and the rewards you have received from them." ) @ConfigEditorBoolean @FeatureToggle @@ -268,47 +268,47 @@ public class GardenConfig { @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 = { - "§e§lVisitor Statistics", - "§e1,636 Total", - "§a1,172§f-§9382§f-§681§f-§c1", - "§21,382 Accepted", - "§c254 Denied", - " ", - "§c62,072 Copper", - "§33.2m Farming EXP", - "§647.2m Coins Spent", - "§b23 §9Flowering Bouquet", - "§b4 §9Overgrown Grass", - "§b2 §5Green Bandana", - "§b1 §9Dedication IV", - "§b6 §b◆ Music Rune I", - "§b1 §cSpace Helmet", - "§b1 §9Cultivating I", - "§b1 §9Replenish I", - " ", // If they want another empty row - "§212,600 Garden EXP", - "§b4.2k Bits", - "§220k Mithril Powder", - "§d18k Gemstone Powder", - } + exampleText = { + "§e§lVisitor Statistics", + "§e1,636 Total", + "§a1,172§f-§9382§f-§681§f-§c1", + "§21,382 Accepted", + "§c254 Denied", + " ", + "§c62,072 Copper", + "§33.2m Farming EXP", + "§647.2m Coins Spent", + "§b23 §9Flowering Bouquet", + "§b4 §9Overgrown Grass", + "§b2 §5Green Bandana", + "§b1 §9Dedication IV", + "§b6 §b◆ Music Rune I", + "§b1 §cSpace Helmet", + "§b1 §9Cultivating I", + "§b1 §9Replenish I", + " ", // If they want another empty row + "§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)); @Expose @ConfigOption(name = "Display Numbers First", desc = "Determines whether the number or drop name displays first. " + - "§eNote: Will not update the preview above!") + "§eNote: Will not update the preview above!") @ConfigEditorBoolean public boolean displayNumbersFirst = true; @Expose @ConfigOption(name = "Display Icons", desc = "Replaces the drop names with icons. " + - "§eNote: Will not update the preview above!") + "§eNote: Will not update the preview above!") @ConfigEditorBoolean public boolean displayIcons = false; @@ -331,6 +331,40 @@ public class GardenConfig { defaultKey = Keyboard.KEY_NONE ) public int acceptHotkey = Keyboard.KEY_NONE; + + @Expose + @ConfigOption( + name = "Highlight Visitors in SkyBlock", + desc = "Highlights Visitors outside of the Garden" + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean highlightVisitors = false; + + + @Expose + @ConfigOption( + name = "Block Interacting with Visitors", + desc = "Blocks you from interacting with / unlocking Visitors to allow for Dedication Cycling" + ) + @ConfigEditorDropdown + public VisitorBlockBehaviour blockInteracting = VisitorBlockBehaviour.ONLY_ON_BINGO; + + public enum VisitorBlockBehaviour { + DONT("Don't"), ALWAYS("Always"), ONLY_ON_BINGO("Only on Bingo"); + + final String str; + + VisitorBlockBehaviour(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + } @Expose @@ -372,9 +406,9 @@ public class GardenConfig { public static class CropMilestonesConfig { @Expose @ConfigOption( - name = "Progress Display", - desc = "Shows the progress and ETA until the next crop milestone is reached and the current crops/minute value. " + - "§eRequires a tool with either a counter or Cultivating enchantment for full accuracy." + name = "Progress Display", + desc = "Shows the progress and ETA until the next crop milestone is reached and the current crops/minute value. " + + "§eRequires a tool with either a counter or Cultivating enchantment for full accuracy." ) @ConfigEditorBoolean @FeatureToggle @@ -382,60 +416,60 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Warn When Close", - desc = "Warn with title and sound when the next crop milestone upgrade happens in 5 seconds. " + - "Useful for switching to a different pet for leveling.") + name = "Warn When Close", + desc = "Warn with title and sound when the next crop milestone upgrade happens in 5 seconds. " + + "Useful for switching to a different pet for leveling.") @ConfigEditorBoolean public boolean warnClose = false; @Expose @ConfigOption( - name = "Time Format", - desc = "Change the highest time unit to show (1h30m vs 90min)") + name = "Time Format", + desc = "Change the highest time unit to show (1h30m vs 90min)") @ConfigEditorDropdown(values = {"Year", "Day", "Hour", "Minute", "Second"}) public Property highestTimeFormat = Property.of(0); @Expose @ConfigOption( - name = "Maxed Milestone", - desc = "Calculate the progress and ETA till maxed milestone (46) instead of next milestone.") + name = "Maxed Milestone", + desc = "Calculate the progress and ETA till maxed milestone (46) instead of next milestone.") @ConfigEditorBoolean public Property bestShowMaxedNeeded = Property.of(false); @Expose @ConfigOption( - name = "Milestone Text", - desc = "Drag text to change the appearance of the overlay.\n" + - "Hold a farming tool to show the overlay." + name = "Milestone Text", + desc = "Drag text to change the appearance of the overlay.\n" + + "Hold a farming tool to show the overlay." ) @ConfigEditorDraggableList( - exampleText = { - "§6Crop Milestones", - "§7Pumpkin Tier 22", - "§e12,300§8/§e100,000", - "§7In §b12m 34s", - "§7Crops/Minute§8: §e12,345", - "§7Blocks/Second§8: §e19.85", - "§7Percentage: §e12.34%", - } + exampleText = { + "§6Crop Milestones", + "§7Pumpkin Tier 22", + "§e12,300§8/§e100,000", + "§7In §b12m 34s", + "§7Crops/Minute§8: §e12,345", + "§7Blocks/Second§8: §e19.85", + "§7Percentage: §e12.34%", + } ) public List text = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5)); @Expose @ConfigOption(name = "Block Broken Precision", desc = "The amount of decimals displayed in blocks/second.") @ConfigEditorSlider( - minValue = 0, - maxValue = 6, - minStep = 1 + minValue = 0, + maxValue = 6, + minStep = 1 ) public int blocksBrokenPrecision = 2; @Expose @ConfigOption(name = "Seconds Before Reset", desc = "How many seconds of not farming until blocks/second resets.") @ConfigEditorSlider( - minValue = 2, - maxValue = 60, - minStep = 1 + minValue = 2, + maxValue = 60, + minStep = 1 ) public int blocksBrokenResetTime = 5; @@ -451,8 +485,8 @@ public class GardenConfig { public static class NextConfig { @Expose @ConfigOption( - name = "Best Display", - desc = "Lists all crops and their ETA till next milestone. Sorts for best crop for getting garden or SkyBlock levels.") + name = "Best Display", + desc = "Lists all crops and their ETA till next milestone. Sorts for best crop for getting garden or SkyBlock levels.") @ConfigEditorBoolean @FeatureToggle public boolean bestDisplay = true; @@ -467,9 +501,9 @@ public class GardenConfig { @Expose @ConfigOption(name = "Only Show Top", desc = "Only show the top # crops.") @ConfigEditorSlider( - minValue = 1, - maxValue = 10, - minStep = 1 + minValue = 1, + maxValue = 10, + minStep = 1 ) public int showOnlyBest = 10; @@ -481,22 +515,22 @@ public class GardenConfig { // TODO moulconfig runnable support @Expose @ConfigOption( - name = "Always On", - desc = "Show the Best Display always while on the garden.") + name = "Always On", + desc = "Show the Best Display always while on the garden.") @ConfigEditorBoolean public boolean bestAlwaysOn = false; @Expose @ConfigOption( - name = "Compact Display", - desc = "A more compact best crop time: Removing the crop name and exp, hide the # number and using a more compact time format.") + name = "Compact Display", + desc = "A more compact best crop time: Removing the crop name and exp, hide the # number and using a more compact time format.") @ConfigEditorBoolean public boolean bestCompact = false; @Expose @ConfigOption( - name = "Hide Title", - desc = "Hides the 'Best Crop Time' line entirely.") + name = "Hide Title", + desc = "Hides the 'Best Crop Time' line entirely.") @ConfigEditorBoolean public boolean bestHideTitle = false; @@ -514,26 +548,26 @@ public class GardenConfig { public static class MushroomPetPerkConfig { @Expose @ConfigOption( - name = "Display Enabled", - desc = "Show the progress and ETA for mushroom crops when farming other crops because of the Mooshroom Cow perk.") + name = "Display Enabled", + desc = "Show the progress and ETA for mushroom crops when farming other crops because of the Mooshroom Cow perk.") @ConfigEditorBoolean @FeatureToggle public boolean enabled = true; @Expose @ConfigOption( - name = "Mushroom Text", - desc = "Drag text to change the appearance of the overlay.\n" + - "Hold a farming tool to show the overlay." + name = "Mushroom Text", + desc = "Drag text to change the appearance of the overlay.\n" + + "Hold a farming tool to show the overlay." ) @ConfigEditorDraggableList( - exampleText = { - "§6Mooshroom Cow Perk", - "§7Mushroom Tier 8", - "§e6,700§8/§e15,000", - "§7In §b12m 34s", - "§7Percentage: §e12.34%", - } + exampleText = { + "§6Mooshroom Cow Perk", + "§7Mushroom Tier 8", + "§e6,700§8/§e15,000", + "§7In §b12m 34s", + "§7Percentage: §e12.34%", + } ) public List text = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); @@ -633,7 +667,7 @@ public class GardenConfig { public static class OptimalSpeedConfig { @Expose @ConfigOption(name = "Enabled", desc = "Show the optimal speed for your current tool in the hand.\n" + - "(Thanks MelonKingDE for the default values).") + "(Thanks MelonKingDE for the default values).") @ConfigEditorBoolean @FeatureToggle public boolean enabled = true; @@ -661,72 +695,72 @@ public class GardenConfig { @Expose @ConfigOption(name = "Wheat", desc = "Suggested farm speed:\n" + - "§e5 Blocks§7: §f✦ 93 speed\n" + - "§e4 Blocks§7: §f✦ 116 speed") + "§e5 Blocks§7: §f✦ 93 speed\n" + + "§e4 Blocks§7: §f✦ 116 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int wheat = 93; @Expose @ConfigOption(name = "Carrot", desc = "Suggested farm speed:\n" + - "§e5 Blocks§7: §f✦ 93 speed\n" + - "§e4 Blocks§7: §f✦ 116 speed") + "§e5 Blocks§7: §f✦ 93 speed\n" + + "§e4 Blocks§7: §f✦ 116 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int carrot = 93; @Expose @ConfigOption(name = "Potato", desc = "Suggested farm speed:\n" + - "§e5 Blocks§7: §f✦ 93 speed\n" + - "§e4 Blocks§7: §f✦ 116 speed") + "§e5 Blocks§7: §f✦ 93 speed\n" + + "§e4 Blocks§7: §f✦ 116 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int potato = 93; @Expose @ConfigOption(name = "Nether Wart", desc = "Suggested farm speed:\n" + - "§e5 Blocks§7: §f✦ 93 speed\n" + - "§e4 Blocks§7: §f✦ 116 speed") + "§e5 Blocks§7: §f✦ 93 speed\n" + + "§e4 Blocks§7: §f✦ 116 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int netherWart = 93; @Expose @ConfigOption(name = "Pumpkin", desc = "Suggested farm speed:\n" + - "§e3 Blocks§7: §f✦ 155 speed\n" + - "§e2 Blocks§7: §f✦ 265 §7or §f400 speed") + "§e3 Blocks§7: §f✦ 155 speed\n" + + "§e2 Blocks§7: §f✦ 265 §7or §f400 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int pumpkin = 155; @Expose @ConfigOption(name = "Melon", desc = "Suggested farm speed:\n" + - "§e3 Blocks§7: §f✦ 155 speed\n" + - "§e2 Blocks§7: §f✦ 265 or 400 speed") + "§e3 Blocks§7: §f✦ 155 speed\n" + + "§e2 Blocks§7: §f✦ 265 or 400 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int melon = 155; @Expose @ConfigOption(name = "Cocoa Beans", desc = "Suggested farm speed:\n" + - "§e3 Blocks§7: §f✦ 155 speed\n" + - "§e4 Blocks§7: §f✦ 116 speed") + "§e3 Blocks§7: §f✦ 155 speed\n" + + "§e4 Blocks§7: §f✦ 116 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int cocoaBeans = 155; // TODO does other speed settings exist? @Expose @ConfigOption(name = "Sugar Cane", desc = "Suggested farm speed:\n" + - "§eYaw 45§7: §f✦ 328 speed") + "§eYaw 45§7: §f✦ 328 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int sugarCane = 328; @Expose @ConfigOption(name = "Cactus", desc = "Suggested farm speed:\n" + - "§eNormal§7: §f✦ 400 speed\n" + - "§eRacing Helmet§7: §f✦ 464 speed\n" + - "§eBlack Cat§7: §f✦ 464 speed") + "§eNormal§7: §f✦ 400 speed\n" + + "§eRacing Helmet§7: §f✦ 464 speed\n" + + "§eBlack Cat§7: §f✦ 464 speed") @ConfigEditorSlider(minValue = 1, maxValue = 500, minStep = 1) public int cactus = 400; // TODO does other speed settings exist? @Expose @ConfigOption(name = "Mushroom", desc = "Suggested farm speed:\n" + - "§eYaw 60§7: §f✦ 233 speed") + "§eYaw 60§7: §f✦ 233 speed") @ConfigEditorSlider(minValue = 1, maxValue = 400, minStep = 1) public int mushroom = 233; } @@ -759,8 +793,8 @@ public class GardenConfig { public static class EliteFarmingWeightConfig { @Expose @ConfigOption(name = "Display", desc = "Display your farming weight on screen. " + - "The calculation and API is provided by The Elite SkyBlock farmers. " + - "See §ehttps://elitebot.dev/info §7for more info.") + "The calculation and API is provided by The Elite SkyBlock farmers. " + + "See §ehttps://elitebot.dev/info §7for more info.") @ConfigEditorBoolean @FeatureToggle public boolean display = true; @@ -770,13 +804,13 @@ public class GardenConfig { @Expose @ConfigOption(name = "Leaderboard Ranking", desc = "Show your position in the farming weight leaderboard. " + - "Only if your farming weight is high enough! Updates every 10 minutes.") + "Only if your farming weight is high enough! Updates every 10 minutes.") @ConfigEditorBoolean public boolean leaderboard = true; @Expose @ConfigOption(name = "Overtake ETA", desc = "Show a timer estimating when you'll move up a spot in the leaderboard! " + - "Will show an ETA to rank #10,000 if you're not on the leaderboard yet.") + "Will show an ETA to rank #10,000 if you're not on the leaderboard yet.") @ConfigEditorBoolean public boolean overtakeETA = false; @@ -831,8 +865,8 @@ public class GardenConfig { public static class MoneyPerHourConfig { @Expose @ConfigOption(name = "Show Money per Hour", - desc = "Displays the money per hour YOU get with YOUR crop/minute value when selling the item to bazaar. " + - "Supports Bountiful, Mushroom Cow Perk, Armor Crops and Dicer Drops. Their toggles are below.") + desc = "Displays the money per hour YOU get with YOUR crop/minute value when selling the item to bazaar. " + + "Supports Bountiful, Mushroom Cow Perk, Armor Crops and Dicer Drops. Their toggles are below.") @ConfigEditorBoolean @FeatureToggle public boolean display = true; @@ -841,9 +875,9 @@ public class GardenConfig { @Expose @ConfigOption(name = "Only Show Top", desc = "Only show the best # items.") @ConfigEditorSlider( - minValue = 1, - maxValue = 25, - minStep = 1 + minValue = 1, + maxValue = 25, + minStep = 1 ) public int showOnlyBest = 5; @@ -855,85 +889,85 @@ public class GardenConfig { // TODO moulconfig runnable support @Expose @ConfigOption( - name = "Always On", - desc = "Always show the money/hour Display while on the garden.") + name = "Always On", + desc = "Always show the money/hour Display while on the garden.") @ConfigEditorBoolean public boolean alwaysOn = false; @Expose @ConfigOption( - name = "Compact Mode", - desc = "Hide the item name and the position number.") + name = "Compact Mode", + desc = "Hide the item name and the position number.") @ConfigEditorBoolean public boolean compact = false; @Expose @ConfigOption( - name = "Compact Price", - desc = "Show the price more compact.") + name = "Compact Price", + desc = "Show the price more compact.") @ConfigEditorBoolean public boolean compactPrice = false; @Expose @ConfigOption( - name = "Use Custom", - desc = "Use the custom format below instead of classic ➜ §eSell Offer §7and other profiles ➜ §eNPC Price.") + name = "Use Custom", + desc = "Use the custom format below instead of classic ➜ §eSell Offer §7and other profiles ➜ §eNPC Price.") @ConfigEditorBoolean public boolean useCustomFormat = false; @Expose @ConfigOption( - name = "Custom Format", - desc = "Set what prices to show") + name = "Custom Format", + desc = "Set what prices to show") @ConfigEditorDraggableList( - exampleText = { - "§eSell Offer", - "§eInstant Sell", - "§eNPC Price" - }, - requireNonEmpty = true + exampleText = { + "§eSell Offer", + "§eInstant Sell", + "§eNPC Price" + }, + requireNonEmpty = true ) public List customFormat = new ArrayList<>(Arrays.asList(0, 1, 2)); @Expose @ConfigOption( - name = "Merge Seeds", - desc = "Merge the seeds price with the wheat price.") + name = "Merge Seeds", + desc = "Merge the seeds price with the wheat price.") @ConfigEditorBoolean public boolean mergeSeeds = true; @Expose @ConfigOption( - name = "Include Bountiful", - desc = "Includes the coins from Bountiful in the calculation.") + name = "Include Bountiful", + desc = "Includes the coins from Bountiful in the calculation.") @ConfigEditorBoolean public boolean bountiful = true; @Expose @ConfigOption( - name = "Include Mooshroom Cow", - desc = "Includes the coins you get from selling the mushrooms from your Mooshroom Cow pet.") + name = "Include Mooshroom Cow", + desc = "Includes the coins you get from selling the mushrooms from your Mooshroom Cow pet.") @ConfigEditorBoolean public boolean mooshroom = true; @Expose @ConfigOption( - name = "Include Armor Drops", - desc = "Includes the average coins/hr from your armor.") + name = "Include Armor Drops", + desc = "Includes the average coins/hr from your armor.") @ConfigEditorBoolean public boolean armor = true; @Expose @ConfigOption( - name = "Include Dicer Drops", - desc = "Includes the average coins/hr from your melon or pumpkin dicer.") + name = "Include Dicer Drops", + desc = "Includes the average coins/hr from your melon or pumpkin dicer.") @ConfigEditorBoolean public boolean dicer = true; @Expose @ConfigOption( - name = "Hide Title", - desc = "Hides the first line of 'Money Per Hour' entirely.") + name = "Hide Title", + desc = "Hides the first line of 'Money Per Hour' entirely.") @ConfigEditorBoolean public boolean hideTitle = false; @@ -981,9 +1015,9 @@ public class GardenConfig { @Expose @ConfigOption(name = "Warning Time", desc = "Set the warning time in seconds before a Jacob's Contest begins.") @ConfigEditorSlider( - minValue = 10, - maxValue = 60 * 5, - minStep = 1 + minValue = 10, + maxValue = 60 * 5, + minStep = 1 ) public int warnTime = 60 * 2; @@ -1027,9 +1061,9 @@ public class GardenConfig { public static class AnitaShopConfig { @Expose @ConfigOption( - name = "Medal Prices", - desc = "Helps to identify profitable items to buy at the Anita item shop " + - "and potential profit from selling the item in the Auction House." + name = "Medal Prices", + desc = "Helps to identify profitable items to buy at the Anita item shop " + + "and potential profit from selling the item in the Auction House." ) @ConfigEditorBoolean @FeatureToggle @@ -1037,8 +1071,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Extra Farming Fortune", - desc = "Show current tier and cost to max out in the item tooltip.") + name = "Extra Farming Fortune", + desc = "Show current tier and cost to max out in the item tooltip.") @ConfigEditorBoolean @FeatureToggle public boolean extraFarmingFortune = true; @@ -1055,8 +1089,8 @@ public class GardenConfig { public static class ComposterConfig { @Expose @ConfigOption( - name = "Composter Overlay", - desc = "Show organic matter, fuel, and profit prices while inside the Composter Inventory." + name = "Composter Overlay", + desc = "Show organic matter, fuel, and profit prices while inside the Composter Inventory." ) @ConfigEditorBoolean @FeatureToggle @@ -1080,8 +1114,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Display Element", - desc = "Displays the Compost data from the tab list as GUI element." + name = "Display Element", + desc = "Displays the Compost data from the tab list as GUI element." ) @ConfigEditorBoolean @FeatureToggle @@ -1089,8 +1123,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Outside Garden", - desc = "Show Time till Composter is empty outside Garden" + name = "Outside Garden", + desc = "Show Time till Composter is empty outside Garden" ) @ConfigEditorBoolean @FeatureToggle @@ -1098,16 +1132,16 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Composter Warning", - desc = "Warn when the Composter gets close to empty, even outside Garden." + name = "Composter Warning", + desc = "Warn when the Composter gets close to empty, even outside Garden." ) @ConfigEditorBoolean public boolean warnAlmostClose = false; @Expose @ConfigOption( - name = "Upgrade Price", - desc = "Show the price for the Composter Upgrade in the lore." + name = "Upgrade Price", + desc = "Show the price for the Composter Upgrade in the lore." ) @ConfigEditorBoolean @FeatureToggle @@ -1115,16 +1149,16 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Round Amount Needed", - desc = "Rounds the amount needed to fill your Composter down so that you don't overspend." + name = "Round Amount Needed", + desc = "Rounds the amount needed to fill your Composter down so that you don't overspend." ) @ConfigEditorBoolean public boolean roundDown = true; @Expose @ConfigOption( - name = "Highlight Upgrade", - desc = "Highlight Upgrades that can be bought right now." + name = "Highlight Upgrade", + desc = "Highlight Upgrades that can be bought right now." ) @ConfigEditorBoolean @FeatureToggle @@ -1132,8 +1166,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Inventory Numbers", - desc = "Show the amount of Organic Matter, Fuel and Composts Available while inside the Composter Inventory." + name = "Inventory Numbers", + desc = "Show the amount of Organic Matter, Fuel and Composts Available while inside the Composter Inventory." ) @ConfigEditorBoolean @FeatureToggle @@ -1159,18 +1193,18 @@ public class GardenConfig { @Expose @ConfigOption(name = "Min Organic Matter", desc = "Warn when Organic Matter is below this value.") @ConfigEditorSlider( - minValue = 1_000, - maxValue = 80_000, - minStep = 1 + minValue = 1_000, + maxValue = 80_000, + minStep = 1 ) public int organicMatter = 20_000; @Expose @ConfigOption(name = "Min Fuel Cap", desc = "Warn when Fuel is below this value.") @ConfigEditorSlider( - minValue = 500, - maxValue = 40_000, - minStep = 1 + minValue = 500, + maxValue = 40_000, + minStep = 1 ) public int fuel = 10_000; } @@ -1190,8 +1224,8 @@ public class GardenConfig { public static class FarmingFortuneConfig { @Expose @ConfigOption( - name = "FF Display", - desc = "Displays the true Farming Fortune for the current crop, including all crop-specific and hidden bonuses." + name = "FF Display", + desc = "Displays the true Farming Fortune for the current crop, including all crop-specific and hidden bonuses." ) @ConfigEditorBoolean @FeatureToggle @@ -1199,9 +1233,9 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Show As Drop Multiplier", - desc = "Adds 100 to the displayed Farming Fortune so that it represents a drop multiplier rather than" + - " the chance for bonus drops. " + name = "Show As Drop Multiplier", + desc = "Adds 100 to the displayed Farming Fortune so that it represents a drop multiplier rather than" + + " the chance for bonus drops. " ) @ConfigEditorBoolean public boolean dropMultiplier = true; @@ -1222,8 +1256,8 @@ public class GardenConfig { public static class TooltipTweaksConfig { @Expose @ConfigOption( - name = "Compact Descriptions", - desc = "Hides redundant parts of reforge descriptions, generic counter description, and Farmhand perk explanation." + name = "Compact Descriptions", + desc = "Hides redundant parts of reforge descriptions, generic counter description, and Farmhand perk explanation." ) @ConfigEditorBoolean @FeatureToggle @@ -1231,26 +1265,26 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Breakdown Hotkey", - desc = "When the keybind is pressed, show a breakdown of all fortune sources on a tool." + name = "Breakdown Hotkey", + desc = "When the keybind is pressed, show a breakdown of all fortune sources on a tool." ) @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LSHIFT) public int fortuneTooltipKeybind = Keyboard.KEY_LSHIFT; @Expose @ConfigOption( - name = "Tooltip Format", - desc = "Show crop-specific Farming Fortune in tooltip.\n" + - "§fShow: §7Crop-specific Fortune indicated as §6[+196]\n" + - "§fReplace: §7Edits the total Fortune to include crop-specific Fortune." + name = "Tooltip Format", + desc = "Show crop-specific Farming Fortune in tooltip.\n" + + "§fShow: §7Crop-specific Fortune indicated as §6[+196]\n" + + "§fReplace: §7Edits the total Fortune to include crop-specific Fortune." ) @ConfigEditorDropdown(values = {"Default", "Show", "Replace"}) public int cropTooltipFortune = 1; @Expose @ConfigOption( - name = "Total Crop Milestone", - desc = "Shows the progress bar till maxed crop milestone in the crop milestone inventory." + name = "Total Crop Milestone", + desc = "Shows the progress bar till maxed crop milestone in the crop milestone inventory." ) @ConfigEditorBoolean @FeatureToggle @@ -1273,27 +1307,27 @@ public class GardenConfig { @Expose @ConfigOption(name = "Yaw Precision", desc = "Yaw precision up to specified decimal.") @ConfigEditorSlider( - minValue = 1, - maxValue = 10, - minStep = 1 + minValue = 1, + maxValue = 10, + minStep = 1 ) public int yawPrecision = 4; @Expose @ConfigOption(name = "Pitch Precision", desc = "Pitch precision up to specified decimal.") @ConfigEditorSlider( - minValue = 1, - maxValue = 10, - minStep = 1 + minValue = 1, + maxValue = 10, + minStep = 1 ) public int pitchPrecision = 4; @Expose @ConfigOption(name = "Display Timeout", desc = "Duration in seconds for which the overlay is being displayed after moving.") @ConfigEditorSlider( - minValue = 1, - maxValue = 20, - minStep = 1 + minValue = 1, + maxValue = 20, + minStep = 1 ) public int timeout = 5; @@ -1386,8 +1420,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "FF for Contest", - desc = "Show the minimum needed Farming Fortune for reaching each medal in Jacob's Farming Contest inventory." + name = "FF for Contest", + desc = "Show the minimum needed Farming Fortune for reaching each medal in Jacob's Farming Contest inventory." ) @ConfigEditorBoolean @FeatureToggle @@ -1398,8 +1432,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Contest Time Needed", - desc = "Show the time and missing FF for every crop inside Jacob's Farming Contest inventory." + name = "Contest Time Needed", + desc = "Show the time and missing FF for every crop inside Jacob's Farming Contest inventory." ) @ConfigEditorBoolean @FeatureToggle @@ -1410,8 +1444,8 @@ public class GardenConfig { @Expose @ConfigOption( - name = "Contest Summary", - desc = "Show the average Blocks Per Second and blocks clicked at the end of a Jacob Farming Contest in chat." + name = "Contest Summary", + desc = "Show the average Blocks Per Second and blocks clicked at the end of a Jacob Farming Contest in chat." ) @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt new file mode 100644 index 000000000..af81f942f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -0,0 +1,101 @@ +package at.hannibal2.skyhanni.features.garden.visitor + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.GardenConfig.VisitorConfig.VisitorBlockBehaviour +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson +import at.hannibal2.skyhanni.utils.toLorenzVec +import io.github.moulberry.notenoughupdates.util.SBInfo +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.network.play.client.C02PacketUseEntity +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightVisitorsOutsideOfGarden { + var visitorJson = mapOf>() + + val config get() = SkyHanniMod.feature.garden.visitors + + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + visitorJson = event.getConstant( + "Garden", GardenJson::class.java + ).visitors.values.groupBy { + it.mode + } + } + + fun getSkinOrTypeFor(entity: Entity): String { + if (entity is EntityPlayer) { + return entity.getSkinTexture() ?: "no skin" + } + return entity.javaClass.simpleName + } + + fun isVisitor(entity: Entity): Boolean { + val mode = SBInfo.getInstance().getLocation() + val possibleJsons = visitorJson[mode] ?: return false + val skinOrType = getSkinOrTypeFor(entity) + return possibleJsons.any { + ((it.position == null) || it.position!!.distance(entity.position.toLorenzVec()) < 1) + && it.skinOrType?.replace("\\n", "")?.replace("\n", "") == skinOrType + } + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!config.highlightVisitors) return + if (!event.repeatSeconds(1)) return + EntityUtils.getEntities() + .filter { it !is EntityArmorStand && isVisitor(it) } + .forEach { + RenderLivingEntityHelper.setEntityColor( + it, + LorenzColor.DARK_RED.toColor().withAlpha(50) + ) { config.highlightVisitors } + } + } + + val shouldBlock + get() = when (config.blockInteracting) { + VisitorBlockBehaviour.DONT -> false + VisitorBlockBehaviour.ALWAYS -> true + VisitorBlockBehaviour.ONLY_ON_BINGO -> SBInfo.getInstance().bingo + null -> false + } + + @SubscribeEvent + fun onClickEntity(event: PacketEvent.SendEvent) { + if (!shouldBlock) return + val world = Minecraft.getMinecraft().theWorld ?: return + val player = Minecraft.getMinecraft().thePlayer ?: return + if (player.isSneaking) return + val packet = event.packet as? C02PacketUseEntity ?: return + val entity = packet.getEntityFromWorld(world) ?: return + if (isVisitor(entity) + || (entity is EntityArmorStand && EntityUtils.getEntitiesNearby( + entity.getLorenzVec(), + 2.0 + ).any { isVisitor(it) }) + ) { + event.isCanceled = true + LorenzUtils.clickableChat( + "§e[SkyHanniBal] Blocked you from interacting with a Visitor. Sneak to bypass or click here to change settings.", + "/sh block interacting with visitors" + ) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt index b7c4ae4a1..97cd1c4ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt @@ -45,6 +45,7 @@ object CopyNearbyEntitiesCommand { resultList.add("name: '" + entity.name + "'") resultList.add("displayName: '${displayName.formattedText}'") resultList.add("entityId: ${entity.entityId}") + resultList.add("uuid version: ${entity.uniqueID.version()} ${if(entity.uniqueID.version() != 4) "NPC " else ""}(${entity.uniqueID})") resultList.add("location data:") resultList.add("- vec: $vec") resultList.add("- distance: $distance") @@ -167,4 +168,4 @@ object CopyNearbyEntitiesCommand { resultList.add("- type: $type") } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java index 87a80d391..265e5b11e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.utils.jsonobjects; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Map; @@ -26,7 +28,24 @@ public class GardenJson { @Expose public String rarity; + @Nullable + @Expose + public LorenzVec position; + + /** + * Formatted as follows: + * - If this visitor is a player, get the encoded skin value + * - If this visitor is a mob, get their mob class name + */ + @Nullable + @Expose + public String skinOrType; + + @Nullable + @Expose + public String mode; + @Expose public List need_items; } -} \ No newline at end of file +} -- cgit