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

Commit

Permalink
修复 海洋-使用万能拼图 无限循环导致使用大量流量的问题;修复 部分系统闪退的问题;优化 海洋-使用万能拼图逻辑;优化 系统计时逻辑;
Browse files Browse the repository at this point in the history
  • Loading branch information
TKaxv-7S committed Jul 22, 2024
1 parent 7e17151 commit ecf6595
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class ProgramChildTaskExecutor implements ChildTaskExecutor {
public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
ThreadPoolExecutor threadPoolExecutor = getChildGroupThreadPool(childTask.getGroup());
Future<?> future;
long time = childTask.getExecTime();
if (time > 0) {
long execTime = childTask.getExecTime();
if (execTime > 0) {
future = threadPoolExecutor.submit(() -> {
if (childTask.getIsCancel()) {
return;
}
//String modelTaskId = getName();
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);
try {
long delay = time - System.currentTimeMillis();
long delay = childTask.getExecTime() - System.currentTimeMillis();
if (delay > 0) {
try {
Thread.sleep(delay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);
Future<?> future = threadPoolExecutor.submit(() -> {
try {
long delay = childTask.getExecTime() - System.currentTimeMillis();
if (delay > 0) {
try {
Thread.sleep(delay);
} catch (Exception e) {
//Log.record("任务模块:" + modelTaskId + " 中断子任务:" + id);
return;
}
}
childTask.run();
} catch (Exception e) {
Log.printStackTrace(e);
Expand All @@ -43,8 +52,14 @@ public Boolean addChildTask(ModelTask.ChildModelTask childTask) {
});
childTask.setCancelTask(() -> future.cancel(true));
};
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
handler.postDelayed(runnable, execTime - System.currentTimeMillis());
long delayMillis = execTime - System.currentTimeMillis();
if (delayMillis > 3000) {
handler.postDelayed(runnable, delayMillis - 2500);
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
} else {
childTask.setCancelTask(() -> handler.removeCallbacks(runnable));
handler.post(runnable);
}
} else {
Future<?> future = threadPoolExecutor.submit(() -> {
//Log.i("任务模块:" + modelTaskId + " 添加子任务:" + id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2213,7 +2213,9 @@ private void letsGetChickenFeedTogether() {
int remainingInvites = 5 - invitedToday;
int invitesToSend = Math.min(canInviteCount, remainingInvites);

if (invitesToSend==0)return;
if (invitesToSend==0) {
return;
}

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

Expand Down Expand Up @@ -2256,7 +2258,6 @@ private void letsGetChickenFeedTogether() {
} catch (JSONException e) {
Log.i(TAG, "letsGetChickenFeedTogether err:");
Log.printStackTrace(e);
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,7 @@ private class BubbleTimerTask extends ChildModelTask {
* Instantiates a new Bubble timer task.
*/
BubbleTimerTask(String ui, long bi, long pt) {
super(AntForestV2.getBubbleTimerTid(ui, bi), pt - 3000 - advanceTimeInt);
super(AntForestV2.getBubbleTimerTid(ui, bi), pt - advanceTimeInt);
userId = ui;
bubbleId = bi;
produceTime = pt;
Expand All @@ -2422,7 +2422,7 @@ public Runnable setRunnable() {
return () -> {
String userName = UserIdMap.getMaskName(userId);
int averageInteger = offsetTimeMath.getAverageInteger();
long readyTime = produceTime + averageInteger - advanceTimeInt - delayTimeMath.getAverageInteger() - System.currentTimeMillis() + 80;
long readyTime = produceTime - advanceTimeInt + averageInteger - delayTimeMath.getAverageInteger() - System.currentTimeMillis() + 70;
if (readyTime > 0) {
try {
Thread.sleep(readyTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import tkaxv7s.xposed.sesame.util.TimeUtil;
import tkaxv7s.xposed.sesame.util.UserIdMap;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.*;

/**
* @author Constanline
Expand Down Expand Up @@ -809,7 +806,7 @@ private static void exchangeProp() {
// 检查道具兑换操作是否成功
if ("SUCCESS".equals(exchangeResultObj.getString("resultCode"))) {
// 输出日志信息
Log.forest("神奇海洋🏖️[制作:万能拼图]" + exchangeNum + "张,剩余" + exchangedPieceNum + "张碎片");
Log.forest("神奇海洋🏖️[万能拼图]制作" + exchangeNum + "张,剩余" + exchangedPieceNum + "张碎片");
// 制作完成后休眠1秒钟
TimeUtil.sleep(1000);
}
Expand Down Expand Up @@ -839,58 +836,60 @@ private static void usePropByType() {
JSONObject propInfo = oceanPropVOByTypeList.getJSONObject(i);
int holdsNum = propInfo.getInt("holdsNum");
// 只要holdsNum大于0,就继续执行循环操作
int pageNum = 0;
th:
while (holdsNum > 0) {
// 查询鱼列表的JSON数据
String fishListJson = AntOceanRpcCall.queryFishList();
pageNum++;
String fishListJson = AntOceanRpcCall.queryFishList(pageNum);
JSONObject fishListObj = new JSONObject(fishListJson);
// 检查是否成功获取到鱼列表并且 hasMore 为 true
if ("SUCCESS".equals(fishListObj.getString("resultCode"))) {
// 获取鱼列表中的fishVOS数组
JSONArray fishVOS = fishListObj.optJSONArray("fishVOS");
// 遍历fishVOS数组,寻找pieces中num值为0的鱼的order和id
for (int j = 0; j < fishVOS.length(); j++) {
JSONObject fish = fishVOS.getJSONObject(j);
JSONArray pieces = fish.optJSONArray("pieces");
if (pieces == null) {
continue;
}
// 遍历pieces数组,寻找num值为0的拼图片段
boolean foundNumZero = false; // 添加一个标志,用来记录是否找到了符合条件的拼图片段
for (int k = 0; k < pieces.length(); k++) {
JSONObject piece = pieces.getJSONObject(k);
int num = piece.getInt("num");
// 找到num值为0的拼图片段
if (num == 0) {
int order = fish.getInt("order");
String id = piece.getString("id");
String name = fish.getString("name");
// 调用usePropByType方法执行道具使用
String usePropResult = AntOceanRpcCall.usePropByType(order, Integer.parseInt(id)); // 传递order和id作为参数
JSONObject usePropResultObj = new JSONObject(usePropResult);
// 检查道具使用操作是否成功
if ("SUCCESS".equals(usePropResultObj.getString("resultCode"))) {
Log.forest("神奇海洋🏖️[使用:万能拼图] | " + name + " |");
TimeUtil.sleep(1000);
holdsNum--; // 每使用一次道具,将holdsNum减1
foundNumZero = true; // 设置标志为true,表示已经找到了符合条件的拼图片段
// 继续下一个鱼的查找
break;
}
if (!"SUCCESS".equals(fishListObj.getString("resultCode"))) {
// 如果没有成功获取到鱼列表或者 hasMore 为 false,则停止后续操作
break;
}
// 获取鱼列表中的fishVOS数组
JSONArray fishVOS = fishListObj.optJSONArray("fishVOS");
if (fishVOS == null) {
break;
}
// 遍历fishVOS数组,寻找pieces中num值为0的鱼的order和id
for (int j = 0; j < fishVOS.length(); j++) {
JSONObject fish = fishVOS.getJSONObject(j);
JSONArray pieces = fish.optJSONArray("pieces");
if (pieces == null) {
continue;
}
int order = fish.getInt("order");
String name = fish.getString("name");
Set<Integer> idSet = new HashSet<>();
for (int k = 0; k < pieces.length(); k++) {
JSONObject piece = pieces.getJSONObject(k);
if (piece.optInt("num") == 0) {
idSet.add(Integer.parseInt(piece.getString("id")));
holdsNum--;
if (holdsNum <= 0) {
break;
}
}
if (foundNumZero) {
// 如果找到了符合条件的拼图片段,就停止遍历fishVOS数组
break;
}
if (!idSet.isEmpty()) {
String usePropResult = AntOceanRpcCall.usePropByType(order, idSet);
JSONObject usePropResultObj = new JSONObject(usePropResult);
if ("SUCCESS".equals(usePropResultObj.getString("resultCode"))) {
int userCount = idSet.size();
Log.forest("神奇海洋🏖️[万能拼图]使用" + userCount + "张,获得[" + name + "]剩余" + holdsNum + "张");
TimeUtil.sleep(1000);
if (holdsNum <= 0) {
break th;
}
}
}
} else {
// 如果没有成功获取到鱼列表或者 hasMore 为 false,则停止后续操作
}
if (!fishListObj.optBoolean("hasMore")) {
break;
}
}
if (holdsNum == 0) {
return; // 结束当前方法的执行
}
}
}
} catch (Throwable t) {
Expand All @@ -900,7 +899,6 @@ private static void usePropByType() {
}



public interface CleanOceanType {

int CLEAN = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package tkaxv7s.xposed.sesame.model.task.antOcean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tkaxv7s.xposed.sesame.hook.ApplicationHook;
import tkaxv7s.xposed.sesame.util.Log;
import tkaxv7s.xposed.sesame.util.RandomUtil;

import java.util.Set;

/**
* @author Constanline
* @since 2023/08/01
Expand Down Expand Up @@ -202,14 +208,30 @@ public static String usePropByTypeList() {
"[{\"propTypeList\":\"UNIVERSAL_PIECE\",\"skipPropId\":false,\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
}

public static String queryFishList() {
public static String queryFishList(int pageNum) {
return ApplicationHook.requestString("alipay.antocean.ocean.h5.queryFishList",
"[{\"combineStatus\":\"UNOBTAINED\",\"needSummary\":\"Y\",\"pageNum\":1,\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"targetUserId\":\"\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
}

public static String usePropByType(int assets, int attachAssets) {
return ApplicationHook.requestString("alipay.antocean.ocean.h5.usePropByType",
"[{\"assetsDetails\":[{\"assets\":" + assets + ",\"assetsNum\":1,\"attachAssets\":" + attachAssets + ",\"propCode\":\"UNIVERSAL_PIECE\"}],\"propCode\":\"UNIVERSAL_PIECE\",\"propType\":\"UNIVERSAL_PIECE\",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
"[{\"combineStatus\":\"UNOBTAINED\",\"needSummary\":\"Y\",\"pageNum\":" + pageNum + ",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"targetUserId\":\"\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
}

public static String usePropByType(int assets, Set<Integer> attachAssetsSet) {
try {
if (!attachAssetsSet.isEmpty()) {
JSONArray jsonArray = new JSONArray();
for (Integer attachAssets : attachAssetsSet) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("assets", assets);
jsonObject.put("assetsNum", 1);
jsonObject.put("attachAssets", attachAssets);
jsonObject.put("propCode", "UNIVERSAL_PIECE");
jsonArray.put(jsonObject);
}
return ApplicationHook.requestString("alipay.antocean.ocean.h5.usePropByType",
"[{\"assetsDetails\":" + jsonArray + ",\"propCode\":\"UNIVERSAL_PIECE\",\"propType\":\"UNIVERSAL_PIECE\",\"source\":\"chInfo_ch_appcenter__chsub_9patch\",\"uniqueId\":\"" + getUniqueId() + "\"}]");
}
} catch (JSONException e) {
Log.printStackTrace(e);
}
return null;
}

}

0 comments on commit ecf6595

Please sign in to comment.