-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: simple ferocity display (#1765)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
da3c40a
commit 4fe2010
Showing
4 changed files
with
77 additions
and
0 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
25 changes: 25 additions & 0 deletions
25
src/main/java/at/hannibal2/skyhanni/config/features/combat/FerocityDisplayConfig.java
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,25 @@ | ||
package at.hannibal2.skyhanni.config.features.combat; | ||
|
||
import at.hannibal2.skyhanni.config.FeatureToggle; | ||
import at.hannibal2.skyhanni.config.core.config.Position; | ||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
|
||
public class FerocityDisplayConfig { | ||
|
||
@Expose | ||
@ConfigOption( | ||
name = "Enabled", | ||
desc = "Show ferocity stat as single gui element. " + | ||
"Requires tab list widget enabled and ferocity selected to work." | ||
) | ||
@ConfigEditorBoolean | ||
@FeatureToggle | ||
public boolean enabled = false; | ||
|
||
@Expose | ||
@ConfigLink(owner = FerocityDisplayConfig.class, field = "enabled") | ||
public Position position = new Position(10, 80, false, true); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.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,45 @@ | ||
package at.hannibal2.skyhanni.features.combat | ||
|
||
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.events.GuiRenderEvent | ||
import at.hannibal2.skyhanni.events.TabListUpdateEvent | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.RenderUtils.renderString | ||
import at.hannibal2.skyhanni.utils.StringUtils.matchFirst | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
class FerocityDisplay { | ||
private val config get() = SkyHanniMod.feature.combat.ferocityDisplay | ||
|
||
/** | ||
* REGEX-TEST: Ferocity: §r§c⫽14 | ||
*/ | ||
private val ferocityPattern by RepoPattern.pattern( | ||
"combat.ferocity.tab", | ||
" Ferocity: §r§c⫽(?<stat>.*)" | ||
) | ||
|
||
private var display = "" | ||
|
||
@SubscribeEvent | ||
fun onTabListUpdate(event: TabListUpdateEvent) { | ||
if (!isEnabled()) return | ||
display = "" | ||
val stat = event.tabList.matchFirst(ferocityPattern) { | ||
group("stat") | ||
} ?: return | ||
|
||
display = "§c⫽$stat" | ||
|
||
} | ||
|
||
@SubscribeEvent | ||
fun onRenderOverlay(event: GuiRenderEvent) { | ||
if (!isEnabled()) return | ||
|
||
config.position.renderString(display, posLabel = "Ferocity Display") | ||
} | ||
|
||
fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled | ||
} |