From b475e06f0c9f0caa79620b0af781d220fc377f53 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 22 Jun 2024 09:55:54 +0200 Subject: Backend: Fix Illegal Mob Detection with Ridable Pets (#2010) Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> --- .../at/hannibal2/skyhanni/data/mob/MobFilter.kt | 49 +++++++++++++++------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data') diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt index ffa2e28f6..fdcc99df1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt @@ -73,20 +73,46 @@ object MobFilter { "filter.dungeon", "^(?:(?✯)\\s)?(?:(?${DungeonAttribute.toRegexLine})\\s)?(?:\\[[\\w\\d]+\\]\\s)?(?[^ᛤ]+)(?: ᛤ)?\\s[^\\s]+$" ) - val summonFilter by repoGroup.pattern("filter.summon", "^(?\\w+)'s (?.*) \\d+.*") - val dojoFilter by repoGroup.pattern("filter.dojo", "^(?:(?\\d+) pts|(?\\w+))$") + val summonFilter by repoGroup.pattern( + "filter.summon", + "^(?\\w+)'s (?.*) \\d+.*" + ) + val dojoFilter by repoGroup.pattern( + "filter.dojo", + "^(?:(?\\d+) pts|(?\\w+))$" + ) val jerryPattern by repoGroup.pattern( "jerry", "(?:\\[\\w+(?\\d+)\\] )?(?\\w+)'s (?\\w+ Jerry) \\d+ Hits" ) - - val petCareNamePattern by repoGroup.pattern("pattern.petcare", "^\\[\\w+ (?\\d+)\\] (?.*)") - val wokeSleepingGolemPattern by repoGroup.pattern("pattern.dungeon.woke.golem", "(?:§c§lWoke|§5§lSleeping) Golem§r") + val petCareNamePattern by repoGroup.pattern( + "pattern.petcare", + "^\\[\\w+ (?\\d+)\\] (?.*)" + ) + val wokeSleepingGolemPattern by repoGroup.pattern( + "pattern.dungeon.woke.golem", + "(?:§c§lWoke|§5§lSleeping) Golem§r" + ) val jerryMagmaCubePattern by repoGroup.pattern( "pattern.jerry.magma.cube", "§c(?:Cubie|Maggie|Cubert|Cübe|Cubette|Magmalene|Lucky 7|8ball|Mega Cube|Super Cube)(?: ᛤ)? §a\\d+§8\\/§a\\d+§c❤" ) - val summonOwnerPattern by repoGroup.pattern("pattern.summon.owner", ".*Spawned by: (?.*).*") + val summonOwnerPattern by repoGroup.pattern( + "pattern.summon.owner", + ".*Spawned by: (?.*).*" + ) + + /** + * REGEX-TEST: §8[§7Lv1§8] §5Horse + * REGEX-TEST: §8[§7Lv52§8] §eArmadillo + * REGEX-TEST: §8[§7Lv12§8] §eSkeleton Horse + * REGEX-TEST: §8[§7Lv49§8] §ePig + * REGEX-TEST: §8[§7Lv64§8] §eRat + */ + val illegalEntitiesPattern by repoGroup.pattern( + "pattern.pet.entities", + "^§8\\[§7Lv\\d+§8] §.(Horse|Armadillo|Skeleton Horse|Pig|Rat)$" + ) internal const val RAT_SKULL = "ewogICJ0aW1lc3RhbXAiIDogMTYxODQxOTcwMTc1MywKICAicHJvZmlsZUlkIiA6ICI3MzgyZGRmYmU0ODU0NTVjODI1ZjkwMGY4OGZkMzJmOCIsCiAgInByb2ZpbGVOYW1lIiA6ICJCdUlJZXQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYThhYmI0NzFkYjBhYjc4NzAzMDExOTc5ZGM4YjQwNzk4YTk0MWYzYTRkZWMzZWM2MWNiZWVjMmFmOGNmZmU4IiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0=" @@ -281,15 +307,9 @@ object MobFilter { ) } return when { - baseEntity is EntityPig && armorStand.name.endsWith("'s Pig") -> MobResult.illegal // Pig Pet - - baseEntity is EntityHorse && armorStand.name.endsWith("'s Skeleton Horse") -> MobResult.illegal// Skeleton Horse Pet - - baseEntity is EntityHorse && armorStand.name.endsWith("'s Horse") -> MobResult.illegal // Horse Pet - + (baseEntity is EntityPig || baseEntity is EntityHorse) && illegalEntitiesPattern.matches(armorStand.name) -> MobResult.illegal baseEntity is EntityGuardian && armorStand.cleanName() .matches("^\\d+".toRegex()) -> MobResult.illegal // Wierd Sea Guardian Ability - else -> null } } @@ -314,8 +334,7 @@ object MobFilter { private fun armorStandOnlyMobs(baseEntity: EntityLivingBase, armorStand: EntityArmorStand): MobResult? { if (baseEntity !is EntityZombie) return null when { - armorStand.name.endsWith("'s Armadillo") -> return MobResult.illegal // Armadillo Pet - armorStand.name.endsWith("'s Rat") -> return MobResult.illegal // Rat Pet + illegalEntitiesPattern.matches(armorStand.name) -> return MobResult.illegal baseEntity.riddenByEntity is EntityPlayer && MobUtils.getArmorStand(baseEntity, 2)?.inventory?.get(4) ?.getSkullTexture() == RAT_SKULL -> return MobResult.illegal // Rat Morph } -- cgit