mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
fix(mapper): score update mapper
This commit is contained in:
@ -5,7 +5,8 @@ import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
|||||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||||
import me.rhunk.snapenhance.mapper.impl.ScoreUpdateMapper
|
import me.rhunk.snapenhance.mapper.impl.ScoreUpdateMapper
|
||||||
import java.lang.reflect.Constructor
|
import kotlin.time.Duration.Companion.days
|
||||||
|
import kotlin.time.Duration.Companion.minutes
|
||||||
|
|
||||||
class NoFriendScoreDelay : Feature("NoFriendScoreDelay", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
class NoFriendScoreDelay : Feature("NoFriendScoreDelay", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||||
override fun onActivityCreate() {
|
override fun onActivityCreate() {
|
||||||
@ -13,9 +14,12 @@ class NoFriendScoreDelay : Feature("NoFriendScoreDelay", loadParams = FeatureLoa
|
|||||||
|
|
||||||
context.mappings.useMapper(ScoreUpdateMapper::class) {
|
context.mappings.useMapper(ScoreUpdateMapper::class) {
|
||||||
classReference.get()?.hookConstructor(HookStage.BEFORE) { param ->
|
classReference.get()?.hookConstructor(HookStage.BEFORE) { param ->
|
||||||
val constructor = param.method() as Constructor<*>
|
param.args().indexOfFirst {
|
||||||
if (constructor.parameterTypes.size < 3 || constructor.parameterTypes[3] != java.util.Collection::class.java) return@hookConstructor
|
val longValue = it.toString().toLongOrNull() ?: return@indexOfFirst false
|
||||||
param.setArg(2, 0L)
|
longValue > 30.minutes.inWholeMilliseconds && longValue < 10.days.inWholeMilliseconds
|
||||||
|
}.takeIf { it != -1 }?.let { index ->
|
||||||
|
param.setArg(index, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@ class ScoreUpdateMapper : AbstractClassMapper("ScoreUpdate") {
|
|||||||
init {
|
init {
|
||||||
mapper {
|
mapper {
|
||||||
for (classDef in classes) {
|
for (classDef in classes) {
|
||||||
classDef.methods.firstOrNull {
|
val toStringMethod = classDef.methods.firstOrNull {
|
||||||
it.name == "<init>" &&
|
it.name == "toString"
|
||||||
it.parameterTypes.size > 4 &&
|
|
||||||
it.parameterTypes[1] == "Ljava/lang/Long;" &&
|
|
||||||
it.parameterTypes[3] == "Ljava/util/Collection;"
|
|
||||||
} ?: continue
|
} ?: continue
|
||||||
if (classDef.methods.firstOrNull {
|
if (classDef.methods.none {
|
||||||
it.name == "toString"
|
it.name == "<init>" &&
|
||||||
}?.implementation?.findConstString("Friend.sq:selectFriendUserScoresNeedToUpdate") != true) continue
|
it.parameterTypes.size > 4
|
||||||
|
}) continue
|
||||||
|
|
||||||
|
if (toStringMethod.implementation?.findConstString("selectFriendUserScoresNeedToUpdate", contains = true) != true) continue
|
||||||
|
|
||||||
classReference.set(classDef.getClassName())
|
classReference.set(classDef.getClassName())
|
||||||
return@mapper
|
return@mapper
|
||||||
|
Reference in New Issue
Block a user