forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Carrolyn (hannibal002#3096)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
a638e64
commit 82060fc
Showing
4 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/at/hannibal2/skyhanni/features/garden/inventory/CarrolynHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package at.hannibal2.skyhanni.features.garden.inventory | ||
|
||
import at.hannibal2.skyhanni.api.event.HandleEvent | ||
import at.hannibal2.skyhanni.data.EntityMovementData | ||
import at.hannibal2.skyhanni.data.IslandGraphs | ||
import at.hannibal2.skyhanni.data.IslandType | ||
import at.hannibal2.skyhanni.events.ItemClickEvent | ||
import at.hannibal2.skyhanni.events.item.ItemHoverEvent | ||
import at.hannibal2.skyhanni.features.garden.GardenAPI | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.ChatUtils | ||
import at.hannibal2.skyhanni.utils.HypixelCommands | ||
import at.hannibal2.skyhanni.utils.ItemUtils.getLore | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.LorenzVec | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matches | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
import net.minecraft.item.ItemStack | ||
|
||
@SkyHanniModule | ||
object CarrolynHelper { | ||
private val config get() = GardenAPI.config | ||
|
||
private val carrolynLocation = LorenzVec(0.5, 103.1, -803.7) | ||
|
||
private val patternGroup = RepoPattern.group("garden.carrolyn") | ||
|
||
/** | ||
* REGEX-TEST: §7Bring §63,000 §7of these to §5Carrolyn §7in | ||
*/ | ||
private val lorePattern by patternGroup.pattern( | ||
"lore", | ||
"§7Bring §63,000 §7of these to §5Carrolyn §7in", | ||
) | ||
|
||
@HandleEvent(priority = HandleEvent.LOWEST) | ||
fun onTooltip(event: ItemHoverEvent) { | ||
if (!isEnabled()) return | ||
|
||
if (!event.itemStack.isCarrolynItem()) return | ||
|
||
event.toolTip.add("") | ||
event.toolTip.add("§eClick to navigate to Carrolyn!") | ||
} | ||
|
||
private fun ItemStack?.isCarrolynItem() = this?.getLore()?.any { lorePattern.matches(it) } ?: false | ||
|
||
@HandleEvent(onlyOnSkyblock = true) | ||
fun onItemClick(event: ItemClickEvent) { | ||
if (!isEnabled()) return | ||
|
||
if (!event.itemInHand.isCarrolynItem()) return | ||
|
||
if (LorenzUtils.skyBlockIsland == IslandType.CRIMSON_ISLE) { | ||
startPathfind() | ||
} else { | ||
ChatUtils.clickableChat( | ||
"Carrolyn is on the Crimson Isle. Click here to warp there!", | ||
onClick = { | ||
HypixelCommands.warp("crimson") | ||
EntityMovementData.onNextTeleport(IslandType.CRIMSON_ISLE) { | ||
startPathfind() | ||
} | ||
}, | ||
replaceSameMessage = true, | ||
) | ||
} | ||
} | ||
|
||
private fun startPathfind() { | ||
IslandGraphs.pathFind(carrolynLocation, "§5Carrolyn", condition = { isEnabled() }) | ||
} | ||
|
||
fun isEnabled() = LorenzUtils.inSkyBlock && config.helpCarrolyn | ||
|
||
} |