diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/data/task/ProgramChildTaskExecutor.java b/app/src/main/java/tkaxv7s/xposed/sesame/data/task/ProgramChildTaskExecutor.java index 0af98d64..a74ff393 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/data/task/ProgramChildTaskExecutor.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/data/task/ProgramChildTaskExecutor.java @@ -15,8 +15,8 @@ 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; @@ -24,7 +24,7 @@ public Boolean addChildTask(ModelTask.ChildModelTask childTask) { //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); diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/data/task/SystemChildTaskExecutor.java b/app/src/main/java/tkaxv7s/xposed/sesame/data/task/SystemChildTaskExecutor.java index 8519f620..ac1369d9 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/data/task/SystemChildTaskExecutor.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/data/task/SystemChildTaskExecutor.java @@ -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); @@ -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); diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antFarm/AntFarm.java b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antFarm/AntFarm.java index c3a9c839..22dfd440 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antFarm/AntFarm.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antFarm/AntFarm.java @@ -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 getFeedSet = getFeedlList.getValue(); @@ -2256,7 +2258,6 @@ private void letsGetChickenFeedTogether() { } catch (JSONException e) { Log.i(TAG, "letsGetChickenFeedTogether err:"); Log.printStackTrace(e); - throw new RuntimeException(e); } } diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antForest/AntForestV2.java b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antForest/AntForestV2.java index f82fd3dc..8e9632c2 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antForest/AntForestV2.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antForest/AntForestV2.java @@ -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; @@ -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); diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOcean.java b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOcean.java index 20496f72..c11989a1 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOcean.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOcean.java @@ -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 @@ -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); } @@ -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 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) { @@ -900,7 +899,6 @@ private static void usePropByType() { } - public interface CleanOceanType { int CLEAN = 0; diff --git a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOceanRpcCall.java b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOceanRpcCall.java index a1069f1d..ffdf5a95 100644 --- a/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOceanRpcCall.java +++ b/app/src/main/java/tkaxv7s/xposed/sesame/model/task/antOcean/AntOceanRpcCall.java @@ -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 @@ -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 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; } } diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable-xxhdpi/logo.png similarity index 100% rename from app/src/main/res/drawable/logo.png rename to app/src/main/res/drawable-xxhdpi/logo.png diff --git a/app/src/main/res/drawable/main.png b/app/src/main/res/drawable-xxhdpi/main.png similarity index 100% rename from app/src/main/res/drawable/main.png rename to app/src/main/res/drawable-xxhdpi/main.png diff --git a/app/src/main/res/drawable/unactivated.png b/app/src/main/res/drawable-xxhdpi/unactivated.png similarity index 100% rename from app/src/main/res/drawable/unactivated.png rename to app/src/main/res/drawable-xxhdpi/unactivated.png