diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-11 15:13:50 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-11 15:13:50 +0100 |
commit | 74a3ac9c70238a7154637c9c2c01690ae9d538ab (patch) | |
tree | 64294e5e787248237527a737eb69ec3e771f6a08 /src/main/java/at/hannibal2/skyhanni/data | |
parent | a634e3326a484f2048259fb64cba623dbcde4370 (diff) | |
download | skyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.tar.gz skyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.tar.bz2 skyhanni-74a3ac9c70238a7154637c9c2c01690ae9d538ab.zip |
Added location fixes to repo.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
4 files changed, 39 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 8b58086a9..22beb125e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -79,7 +79,7 @@ class HypixelData { .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } ?.substring(5)?.removeColor() ?: "?" - skyBlockArea = LocationData.fixLocation(skyBlockIsland) ?: originalLocation + skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation checkProfileName() } @@ -174,7 +174,7 @@ class HypixelData { } private fun getIslandType(newIsland: String, guesting: Boolean): IslandType { - val islandType = IslandType.getBySidebarName(newIsland) + val islandType = IslandType.getByNameOrUnknown(newIsland) if (guesting) { if (islandType == IslandType.PRIVATE_ISLAND) return IslandType.PRIVATE_ISLAND_GUEST if (islandType == IslandType.GARDEN) return IslandType.GARDEN_GUEST diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 15195dec4..3ab213025 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -28,8 +28,9 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { ; companion object { - fun getBySidebarName(name: String): IslandType { - return entries.firstOrNull { it.displayName == name } ?: UNKNOWN - } + fun getByNameOrUnknown(name: String) = getByNameOrNull(name) ?: UNKNOWN + fun getByName(name: String) = getByNameOrNull(name) ?: error("IslandType not found: '$name'") + + fun getByNameOrNull(name: String) = entries.firstOrNull { it.displayName == name } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationData.kt deleted file mode 100644 index 58ffec3f8..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/LocationData.kt +++ /dev/null @@ -1,22 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside -import net.minecraft.util.AxisAlignedBB - -object LocationData { - 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) - private val fakeZealotBruiserHideoutArea = AxisAlignedBB(-520.0, 66.0, -332.0, -558.0, 85.0, -280.0) - private val realZealotBruiserHideoutArea = AxisAlignedBB(-552.0, 50.0, -245.0, -580.0, 72.0, -209.0) - private val leftStronghold = AxisAlignedBB(-463.7, 94.0, -518.3, -435.3, 115.0, -547.7) - - fun fixLocation(skyBlockIsland: IslandType) = when { - skyBlockIsland == IslandType.THE_RIFT && westVillageFarmArea.isPlayerInside() -> "Dreadfarm" - skyBlockIsland == IslandType.THE_PARK && howlingCaveArea.isPlayerInside() -> "Howling Cave" - skyBlockIsland == IslandType.THE_END && fakeZealotBruiserHideoutArea.isPlayerInside() -> "The End" - skyBlockIsland == IslandType.THE_END && realZealotBruiserHideoutArea.isPlayerInside() -> "Zealot Bruiser Hideout" - skyBlockIsland == IslandType.CRIMSON_ISLE && leftStronghold.isPlayerInside() -> "Stronghold" - - else -> null - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt new file mode 100644 index 000000000..2bd6a9dcb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside +import at.hannibal2.skyhanni.utils.jsonobjects.LocationFixJson +import net.minecraft.util.AxisAlignedBB +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object LocationFixData { + private var locationFixes = mutableListOf<LocationFix>() + + class LocationFix(val island: IslandType, val area: AxisAlignedBB, val realLocation: String) + + // priority set to low so that IslandType can load their island names from repo earlier + @SubscribeEvent(priority = EventPriority.LOW) + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<LocationFixJson>("LocationFix") + locationFixes.clear() + + for (fix in data.locationFixes.values) { + val island = IslandType.getByName(fix.island_name) + val area = fix.a.axisAlignedTo(fix.b) + val realLocation = fix.real_location + + locationFixes.add(LocationFix(island, area, realLocation)) + } + } + + fun fixLocation(skyBlockIsland: IslandType) = locationFixes + .firstOrNull { skyBlockIsland == it.island && it.area.isPlayerInside() } + ?.realLocation +} |