From 61feb23f164cbed58e1a8e60553a0b34ba2a1736 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Fri, 22 Apr 2022 00:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=A9=E5=9B=BE=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AF=8F=E6=97=A5=E7=BB=9F=E8=AE=A1=E6=B2=A1?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yutou/qqbot/models/Model.java | 2 +- src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/models/Model.java b/src/main/java/com/yutou/qqbot/models/Model.java index 381af07..1d2f95c 100644 --- a/src/main/java/com/yutou/qqbot/models/Model.java +++ b/src/main/java/com/yutou/qqbot/models/Model.java @@ -79,7 +79,7 @@ public abstract class Model implements ModelInterface { } } - public void onTime(Long qq,String time) { + public synchronized void onTime(Long qq,String time) { } public static StringBuilder getCommands(Class commands) { diff --git a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java index 5f8e232..b4cdc7e 100644 --- a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java +++ b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java @@ -18,9 +18,9 @@ import java.util.TimerTask; public class ApplicationInit implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - Log.i("ApplicationInit run"); new Timer().schedule(new TimerTask() { private String oldTime = ""; + @Override public void run() { try { @@ -29,14 +29,15 @@ public class ApplicationInit implements ApplicationRunner { return; } oldTime = time; + Log.i("ApplicationInit run > "+oldTime ); for (Class model : Model.classList) { new Thread(() -> { try { Bot bot = QQBotManager.getInstance().getBot(); Model useModel = (Model) model.getDeclaredConstructor().newInstance(); for (Group group : bot.getGroups()) { - if(QQNumberManager.getManager().isUseModel(group.getId(),model)){ - useModel.onTime(group.getId(),time); + if (QQNumberManager.getManager().isUseModel(group.getId(), model)) { + useModel.onTime(group.getId(), time); } } } catch (Exception e) {