-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
- Loading branch information
1 parent
7aea6aa
commit c48d82d
Showing
7 changed files
with
84 additions
and
4 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
19 changes: 19 additions & 0 deletions
19
src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetNametagConfig.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,19 @@ | ||
package at.hannibal2.skyhanni.config.features.misc.pets; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
|
||
public class PetNametagConfig { | ||
|
||
@Expose | ||
@ConfigOption(name = "Hide Pet Level", desc = "Hide the pet level above the pet.") | ||
@ConfigEditorBoolean | ||
public boolean hidePetLevel = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Hide Max Pet Level", desc = "Hide the pet level above the pet if it is max level.") | ||
@ConfigEditorBoolean | ||
public boolean hideMaxPetLevel = false; | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...yhanni/features/misc/CurrentPetDisplay.kt → ...i/features/misc/pets/CurrentPetDisplay.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
2 changes: 1 addition & 1 deletion
2
...anni/features/misc/PetCandyUsedDisplay.kt → ...features/misc/pets/PetCandyUsedDisplay.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
2 changes: 1 addition & 1 deletion
2
...2/skyhanni/features/misc/PetExpTooltip.kt → ...hanni/features/misc/pets/PetExpTooltip.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
2 changes: 1 addition & 1 deletion
2
.../skyhanni/features/misc/PetItemDisplay.kt → ...anni/features/misc/pets/PetItemDisplay.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
56 changes: 56 additions & 0 deletions
56
src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.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,56 @@ | ||
package at.hannibal2.skyhanni.features.misc.pets | ||
|
||
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt | ||
import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher | ||
import at.hannibal2.skyhanni.utils.chat.Text.asComponent | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
import net.minecraft.entity.item.EntityArmorStand | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
@SkyHanniModule | ||
object PetNametag { | ||
|
||
private val config get() = SkyHanniMod.feature.misc.pets.nametag | ||
|
||
/** | ||
* REGEX-TEST: §8[§7Lv99§8] Ammonite | ||
* REGEX-TEST: §8[§7Lv100§8] Endermite§5 ✦ | ||
*/ | ||
private val petNametagPattern by RepoPattern.pattern( | ||
"pet.nametag", | ||
"(?<start>§8\\[§7Lv(?<lvl>\\d+)§8]) (?<rarity>§.)(?<pet>[\\w\\s]+)(?<skin>§. ✦)?", | ||
) | ||
|
||
@SubscribeEvent | ||
fun onNameTagRender(event: EntityDisplayNameEvent) { | ||
if (!isEnabled()) return | ||
if (event.entity !is EntityArmorStand) return | ||
|
||
petNametagPattern.matchMatcher(event.chatComponent.unformattedText) { | ||
val start = group("start") | ||
val lvl = group("lvl").formatInt() | ||
val rarity = group("rarity") | ||
val pet = group("pet") | ||
val skin = groupOrNull("skin") ?: "" | ||
|
||
val hideLevel = config.hidePetLevel | ||
val hideMaxLevel = config.hideMaxPetLevel && (lvl == 100 || lvl == 200) | ||
|
||
val text = buildString { | ||
if (!hideLevel && !hideMaxLevel) { | ||
append(start) | ||
} | ||
append(rarity + pet + skin) | ||
} | ||
|
||
event.chatComponent = text.asComponent() | ||
} | ||
} | ||
|
||
private fun isEnabled() = LorenzUtils.inSkyBlock && (config.hidePetLevel || config.hideMaxPetLevel) | ||
} |