Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ecf6595

Browse files
committed
修复 海洋-使用万能拼图 无限循环导致使用大量流量的问题;修复 部分系统闪退的问题;优化 海洋-使用万能拼图逻辑;优化 系统计时逻辑;
1 parent 7e17151 commit ecf6595

File tree

9 files changed

+99
-63
lines changed

9 files changed

+99
-63
lines changed

app/src/main/java/tkaxv7s/xposed/sesame/data/task/ProgramChildTaskExecutor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ public class ProgramChildTaskExecutor implements ChildTaskExecutor {
1515
public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
1616
ThreadPoolExecutor threadPoolExecutor = getChildGroupThreadPool(childTask.getGroup());
1717
Future<?> future;
18-
long time = childTask.getExecTime();
19-
if (time > 0) {
18+
long execTime = childTask.getExecTime();
19+
if (execTime > 0) {
2020
future = threadPoolExecutor.submit(() -> {
2121
if (childTask.getIsCancel()) {
2222
return;
2323
}
2424
//String modelTaskId = getName();
2525
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);
2626
try {
27-
long delay = time - System.currentTimeMillis();
27+
long delay = childTask.getExecTime() - System.currentTimeMillis();
2828
if (delay > 0) {
2929
try {
3030
Thread.sleep(delay);

app/src/main/java/tkaxv7s/xposed/sesame/data/task/SystemChildTaskExecutor.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
3232
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);
3333
Future<?> future = threadPoolExecutor.submit(() -> {
3434
try {
35+
long delay = childTask.getExecTime() - System.currentTimeMillis();
36+
if (delay > 0) {
37+
try {
38+
Thread.sleep(delay);
39+
} catch (Exception e) {
40+
//Log.record("任务模块:" + modelTaskId + " 中断子任务:" + id);
41+
return;
42+
}
43+
}
3544
childTask.run();
3645
} catch (Exception e) {
3746
Log.printStackTrace(e);
@@ -43,8 +52,14 @@ public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
4352
});
4453
childTask.setCancelTask(() -> future.cancel(true));
4554
};
46-
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
47-
handler.postDelayed(runnable, execTime - System.currentTimeMillis());
55+
long delayMillis = execTime - System.currentTimeMillis();
56+
if (delayMillis > 3000) {
57+
handler.postDelayed(runnable, delayMillis - 2500);
58+
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
59+
} else {
60+
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
61+
handler.post(runnable);
62+
}
4863
} else {
4964
Future<?> future = threadPoolExecutor.submit(() -> {
5065
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);

app/src/main/java/tkaxv7s/xposed/sesame/model/task/antFarm/AntFarm.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,9 @@ private void letsGetChickenFeedTogether() {
22132213
int remainingInvites = 5 - invitedToday;
22142214
int invitesToSend = Math.min(canInviteCount, remainingInvites);
22152215

2216-
if (invitesToSend==0)return;
2216+
if (invitesToSend==0) {
2217+
return;
2218+
}
22172219

22182220
Set<String> getFeedSet = getFeedlList.getValue();
22192221

@@ -2256,7 +2258,6 @@ private void letsGetChickenFeedTogether() {
22562258
} catch (JSONException e) {
22572259
Log.i(TAG, "letsGetChickenFeedTogether err:");
22582260
Log.printStackTrace(e);
2259-
throw new RuntimeException(e);
22602261
}
22612262
}
22622263

app/src/main/java/tkaxv7s/xposed/sesame/model/task/antForest/AntForestV2.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ private class BubbleTimerTask extends ChildModelTask {
24112411
* Instantiates a new Bubble timer task.
24122412
*/
24132413
BubbleTimerTask(String ui, long bi, long pt) {
2414-
super(AntForestV2.getBubbleTimerTid(ui, bi), pt - 3000 - advanceTimeInt);
2414+
super(AntForestV2.getBubbleTimerTid(ui, bi), pt - advanceTimeInt);
24152415
userId = ui;
24162416
bubbleId = bi;
24172417
produceTime = pt;
@@ -2422,7 +2422,7 @@ public Runnable setRunnable() {
24222422
return () -> {
24232423
String userName = UserIdMap.getMaskName(userId);
24242424
int averageInteger = offsetTimeMath.getAverageInteger();
2425-
long readyTime = produceTime + averageInteger - advanceTimeInt - delayTimeMath.getAverageInteger() - System.currentTimeMillis() + 80;
2425+
long readyTime = produceTime - advanceTimeInt + averageInteger - delayTimeMath.getAverageInteger() - System.currentTimeMillis() + 70;
24262426
if (readyTime > 0) {
24272427
try {
24282428
Thread.sleep(readyTime);

app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOcean.java

+45-47
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
import tkaxv7s.xposed.sesame.util.TimeUtil;
2020
import tkaxv7s.xposed.sesame.util.UserIdMap;
2121

22-
import java.util.LinkedHashMap;
23-
import java.util.LinkedHashSet;
24-
import java.util.Map;
25-
import java.util.Objects;
22+
import java.util.*;
2623

2724
/**
2825
* @author Constanline
@@ -809,7 +806,7 @@ private static void exchangeProp() {
809806
// 检查道具兑换操作是否成功
810807
if ("SUCCESS".equals(exchangeResultObj.getString("resultCode"))) {
811808
// 输出日志信息
812-
Log.forest("神奇海洋🏖️[制作:万能拼图]" + exchangeNum + "张,剩余" + exchangedPieceNum + "张碎片");
809+
Log.forest("神奇海洋🏖️[万能拼图]制作" + exchangeNum + "张,剩余" + exchangedPieceNum + "张碎片");
813810
// 制作完成后休眠1秒钟
814811
TimeUtil.sleep(1000);
815812
}
@@ -839,58 +836,60 @@ private static void usePropByType() {
839836
JSONObject propInfo = oceanPropVOByTypeList.getJSONObject(i);
840837
int holdsNum = propInfo.getInt("holdsNum");
841838
// 只要holdsNum大于0,就继续执行循环操作
839+
int pageNum = 0;
840+
th:
842841
while (holdsNum > 0) {
843842
// 查询鱼列表的JSON数据
844-
String fishListJson = AntOceanRpcCall.queryFishList();
843+
pageNum++;
844+
String fishListJson = AntOceanRpcCall.queryFishList(pageNum);
845845
JSONObject fishListObj = new JSONObject(fishListJson);
846846
// 检查是否成功获取到鱼列表并且 hasMore 为 true
847-
if ("SUCCESS".equals(fishListObj.getString("resultCode"))) {
848-
// 获取鱼列表中的fishVOS数组
849-
JSONArray fishVOS = fishListObj.optJSONArray("fishVOS");
850-
// 遍历fishVOS数组,寻找pieces中num值为0的鱼的order和id
851-
for (int j = 0; j < fishVOS.length(); j++) {
852-
JSONObject fish = fishVOS.getJSONObject(j);
853-
JSONArray pieces = fish.optJSONArray("pieces");
854-
if (pieces == null) {
855-
continue;
856-
}
857-
// 遍历pieces数组,寻找num值为0的拼图片段
858-
boolean foundNumZero = false; // 添加一个标志,用来记录是否找到了符合条件的拼图片段
859-
for (int k = 0; k < pieces.length(); k++) {
860-
JSONObject piece = pieces.getJSONObject(k);
861-
int num = piece.getInt("num");
862-
// 找到num值为0的拼图片段
863-
if (num == 0) {
864-
int order = fish.getInt("order");
865-
String id = piece.getString("id");
866-
String name = fish.getString("name");
867-
// 调用usePropByType方法执行道具使用
868-
String usePropResult = AntOceanRpcCall.usePropByType(order, Integer.parseInt(id)); // 传递order和id作为参数
869-
JSONObject usePropResultObj = new JSONObject(usePropResult);
870-
// 检查道具使用操作是否成功
871-
if ("SUCCESS".equals(usePropResultObj.getString("resultCode"))) {
872-
Log.forest("神奇海洋🏖️[使用:万能拼图] | " + name + " |");
873-
TimeUtil.sleep(1000);
874-
holdsNum--; // 每使用一次道具,将holdsNum减1
875-
foundNumZero = true; // 设置标志为true,表示已经找到了符合条件的拼图片段
876-
// 继续下一个鱼的查找
877-
break;
878-
}
847+
if (!"SUCCESS".equals(fishListObj.getString("resultCode"))) {
848+
// 如果没有成功获取到鱼列表或者 hasMore 为 false,则停止后续操作
849+
break;
850+
}
851+
// 获取鱼列表中的fishVOS数组
852+
JSONArray fishVOS = fishListObj.optJSONArray("fishVOS");
853+
if (fishVOS == null) {
854+
break;
855+
}
856+
// 遍历fishVOS数组,寻找pieces中num值为0的鱼的order和id
857+
for (int j = 0; j < fishVOS.length(); j++) {
858+
JSONObject fish = fishVOS.getJSONObject(j);
859+
JSONArray pieces = fish.optJSONArray("pieces");
860+
if (pieces == null) {
861+
continue;
862+
}
863+
int order = fish.getInt("order");
864+
String name = fish.getString("name");
865+
Set<Integer> idSet = new HashSet<>();
866+
for (int k = 0; k < pieces.length(); k++) {
867+
JSONObject piece = pieces.getJSONObject(k);
868+
if (piece.optInt("num") == 0) {
869+
idSet.add(Integer.parseInt(piece.getString("id")));
870+
holdsNum--;
871+
if (holdsNum <= 0) {
872+
break;
879873
}
880874
}
881-
if (foundNumZero) {
882-
// 如果找到了符合条件的拼图片段,就停止遍历fishVOS数组
883-
break;
875+
}
876+
if (!idSet.isEmpty()) {
877+
String usePropResult = AntOceanRpcCall.usePropByType(order, idSet);
878+
JSONObject usePropResultObj = new JSONObject(usePropResult);
879+
if ("SUCCESS".equals(usePropResultObj.getString("resultCode"))) {
880+
int userCount = idSet.size();
881+
Log.forest("神奇海洋🏖️[万能拼图]使用" + userCount + "张,获得[" + name + "]剩余" + holdsNum + "张");
882+
TimeUtil.sleep(1000);
883+
if (holdsNum <= 0) {
884+
break th;
885+
}
884886
}
885887
}
886-
} else {
887-
// 如果没有成功获取到鱼列表或者 hasMore 为 false,则停止后续操作
888+
}
889+
if (!fishListObj.optBoolean("hasMore")) {
888890
break;
889891
}
890892
}
891-
if (holdsNum == 0) {
892-
return; // 结束当前方法的执行
893-
}
894893
}
895894
}
896895
} catch (Throwable t) {
@@ -900,7 +899,6 @@ private static void usePropByType() {
900899
}
901900

902901

903-
904902
public interface CleanOceanType {
905903

906904
int CLEAN = 0;

app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOceanRpcCall.java

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package tkaxv7s.xposed.sesame.model.task.antOcean;
22

3+
import org.json.JSONArray;
4+
import org.json.JSONException;
5+
import org.json.JSONObject;
36
import tkaxv7s.xposed.sesame.hook.ApplicationHook;
7+
import tkaxv7s.xposed.sesame.util.Log;
48
import tkaxv7s.xposed.sesame.util.RandomUtil;
59

10+
import java.util.Set;
11+
612
/**
713
* @author Constanline
814
* @since 2023/08/01
@@ -202,14 +208,30 @@ public static String usePropByTypeList() {
202208
"[{\"propTypeList\":\"UNIVERSAL_PIECE\",\"skipPropId\":false,\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
203209
}
204210

205-
public static String queryFishList() {
211+
public static String queryFishList(int pageNum) {
206212
return ApplicationHook.requestString("alipay.antocean.ocean.h5.queryFishList",
207-
"[{\"combineStatus\":\"UNOBTAINED\",\"needSummary\":\"Y\",\"pageNum\":1,\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"targetUserId\":\"\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
208-
}
209-
210-
public static String usePropByType(int assets, int attachAssets) {
211-
return ApplicationHook.requestString("alipay.antocean.ocean.h5.usePropByType",
212-
"[{\"assetsDetails\":[{\"assets\":" + assets + ",\"assetsNum\":1,\"attachAssets\":" + attachAssets + ",\"propCode\":\"UNIVERSAL_PIECE\"}],\"propCode\":\"UNIVERSAL_PIECE\",\"propType\":\"UNIVERSAL_PIECE\",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
213+
"[{\"combineStatus\":\"UNOBTAINED\",\"needSummary\":\"Y\",\"pageNum\":" + pageNum + ",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"targetUserId\":\"\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
214+
}
215+
216+
public static String usePropByType(int assets, Set<Integer> attachAssetsSet) {
217+
try {
218+
if (!attachAssetsSet.isEmpty()) {
219+
JSONArray jsonArray = new JSONArray();
220+
for (Integer attachAssets : attachAssetsSet) {
221+
JSONObject jsonObject = new JSONObject();
222+
jsonObject.put("assets", assets);
223+
jsonObject.put("assetsNum", 1);
224+
jsonObject.put("attachAssets", attachAssets);
225+
jsonObject.put("propCode", "UNIVERSAL_PIECE");
226+
jsonArray.put(jsonObject);
227+
}
228+
return ApplicationHook.requestString("alipay.antocean.ocean.h5.usePropByType",
229+
"[{\"assetsDetails\":" + jsonArray + ",\"propCode\":\"UNIVERSAL_PIECE\",\"propType\":\"UNIVERSAL_PIECE\",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
230+
}
231+
} catch (JSONException e) {
232+
Log.printStackTrace(e);
233+
}
234+
return null;
213235
}
214236

215237
}

0 commit comments

Comments
 (0)