@@ -4,9 +4,6 @@ import net.minecraft.client.Minecraft
44import org.apache.logging.log4j.LogManager
55import org.polyfrost.oneconfig.api.event.v1.eventHandler
66import org.polyfrost.oneconfig.api.event.v1.events.TickEvent
7- import org.polyfrost.oneconfig.api.hud.v1.Font
8- import org.polyfrost.oneconfig.api.hud.v1.Hud
9- import org.polyfrost.oneconfig.api.hud.v1.HudManager
107import org.polyfrost.oneconfig.internal.ui.themes.MinecraftDark
118import org.polyfrost.oneconfig.internal.ui.themes.MinecraftLight
129import org.polyfrost.oneconfig.internal.ui.themes.PolyGlassDark
@@ -19,10 +16,9 @@ object OnboardingFeatures {
1916
2017 val polySprintAvailable: Boolean by lazy { classExists(POLYSPRINT_CONFIG ) }
2118 val polyBlurAvailable: Boolean by lazy { classExists(POLYBLUR_CONFIG ) }
22- val evergreenAvailable: Boolean by lazy { classExists(EVERGREEN_FPS ) }
2319
2420 val modsPageAvailable: Boolean
25- get() = polySprintAvailable || polyBlurAvailable || evergreenAvailable
21+ get() = polySprintAvailable || polyBlurAvailable
2622
2723 fun initialize () {
2824 eventHandler { _: TickEvent .End ->
@@ -43,12 +39,6 @@ object OnboardingFeatures {
4339 changed = true
4440 }
4541 }
46- if (evergreenAvailable && ! PolyPlusConfig .onboardingEvergreenApplied) {
47- if (applyEvergreenHuds()) {
48- PolyPlusConfig .onboardingEvergreenApplied = true
49- changed = true
50- }
51- }
5242 if (changed) PolyPlusConfig .save()
5343 }
5444 }
@@ -62,9 +52,6 @@ object OnboardingFeatures {
6252 if (applyPolyBlur(PolyPlusConfig .onboardingMotionBlur)) {
6353 PolyPlusConfig .onboardingPolyBlurApplied = true
6454 }
65- if (applyEvergreenHuds()) {
66- PolyPlusConfig .onboardingEvergreenApplied = true
67- }
6855 PolyPlusConfig .save()
6956 }
7057
@@ -73,7 +60,7 @@ object OnboardingFeatures {
7360 PolyPlusConfig .onboardingFeaturesApplied = true
7461 }
7562
76- private fun applyTheme (light : Boolean , style : Int ) {
63+ fun applyTheme (light : Boolean , style : Int ) {
7764 val theme = when {
7865 style == 1 && light -> MinecraftLight
7966 style == 1 -> MinecraftDark
@@ -90,54 +77,6 @@ object OnboardingFeatures {
9077 }.onFailure { logger.warn(" Could not apply toggle sprint preference" , it) }
9178 }
9279
93- private fun applyEvergreenHuds (): Boolean {
94- val choices = listOf (
95- HudChoice (PolyPlusConfig .onboardingHudFps, EVERGREEN_FPS ),
96- HudChoice (PolyPlusConfig .onboardingHudCps, EVERGREEN_CPS ),
97- HudChoice (PolyPlusConfig .onboardingHudPing, EVERGREEN_PING ),
98- HudChoice (PolyPlusConfig .onboardingHudTime, EVERGREEN_TIME ),
99- )
100- var found = false
101- choices.forEach { choice ->
102- val type = hudClass(choice.className) ? : return @forEach
103- found = applyHud(type, choice.enabled) || found
104- }
105-
106- val positionType = hudClass(EVERGREEN_POSITION )
107- if (positionType != null ) {
108- val enabled = PolyPlusConfig .onboardingHudCoords || PolyPlusConfig .onboardingHudDirection
109- found = applyHud(positionType, enabled) { hud ->
110- setBoolean(hud, " setShowDirection" , PolyPlusConfig .onboardingHudDirection)
111- setBoolean(hud, " setShowAxis" , PolyPlusConfig .onboardingHudCoords)
112- setBoolean(hud, " setShowX" , PolyPlusConfig .onboardingHudCoords || PolyPlusConfig .onboardingHudDirection)
113- setBoolean(hud, " setShowY" , PolyPlusConfig .onboardingHudCoords)
114- setBoolean(hud, " setShowZ" , PolyPlusConfig .onboardingHudCoords || PolyPlusConfig .onboardingHudDirection)
115- } || found
116- }
117- return found
118- }
119-
120- private fun applyHud (type : Class <out Hud >, enabled : Boolean , configure : (Hud ) -> Unit = {}): Boolean {
121- val provider = HudManager .getProvider(type) ? : return false
122- styleHud(provider)
123- configure(provider)
124- HudManager .toggleAllHuds(provider, ! enabled)
125- HudManager .getHudsOfType(type).forEach {
126- styleHud(it)
127- configure(it)
128- it.hidden = ! enabled
129- runCatching { it.save() }
130- }
131- return true
132- }
133-
134- private fun styleHud (hud : Hud ) {
135- val polyGlass = PolyPlusConfig .onboardingHudStyle == 0
136- hud.font = if (polyGlass) Font .Poppins else Font .Minecraft
137- hud.bgRadius = if (polyGlass) 4f else 0f
138- hud.showBackground = true
139- }
140-
14180 private fun applyPolyBlur (value : Int ): Boolean {
14281 val strength = value.coerceIn(0 , 10 )
14382 return runCatching {
@@ -156,25 +95,6 @@ object OnboardingFeatures {
15695
15796 private fun classExists (name : String ) = runCatching { Class .forName(name, false , javaClass.classLoader) }.isSuccess
15897
159- @Suppress(" UNCHECKED_CAST" )
160- private fun hudClass (name : String ): Class <out Hud >? =
161- runCatching { Class .forName(name, false , javaClass.classLoader) as Class <out Hud > }.getOrNull()
162-
163- private fun setBoolean (target : Any , setter : String , value : Boolean ) {
164- runCatching { target.javaClass.getMethod(setter, Boolean ::class .javaPrimitiveType).invoke(target, value) }
165- .onFailure { logger.warn(" Could not apply EvergreenHUD option {}" , setter, it) }
166- }
167-
168- private data class HudChoice (
169- val enabled : Boolean ,
170- val className : String ,
171- )
172-
17398 private const val POLYSPRINT_CONFIG = " org.polyfrost.polysprint.client.PolySprintConfig"
17499 private const val POLYBLUR_CONFIG = " org.polyfrost.polyblur.client.PolyBlurConfig"
175- private const val EVERGREEN_FPS = " org.polyfrost.evergreenhud.client.hud.FpsHud"
176- private const val EVERGREEN_CPS = " org.polyfrost.evergreenhud.client.hud.CpsHud"
177- private const val EVERGREEN_PING = " org.polyfrost.evergreenhud.client.hud.PingHud"
178- private const val EVERGREEN_TIME = " org.polyfrost.evergreenhud.client.hud.clock.DigitalClockHud"
179- private const val EVERGREEN_POSITION = " org.polyfrost.evergreenhud.client.hud.PositionHud"
180100}
0 commit comments