Skip to content

Commit

Permalink
fix: 调用saveDefaultConfig()时,如config.yml为空文件将阻塞主线程
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorOSS committed Feb 27, 2024
1 parent cf0a96c commit 2169210
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.meteor</groupId>
<artifactId>wechat-bc</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.1.2-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.meteor</groupId>
<artifactId>wechat-bc</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.1.3-SNAPSHOT</version>

<distributionManagement>
<repository>
Expand Down
6 changes: 3 additions & 3 deletions release_info.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v1.1.2
DESCRIPTION=feat: 消息撤回接口
feat: RevokeMessage
VERSION=v1.1.3
DESCRIPTION=fix: 调用saveDefaultConfig()时,如config.yml为空文件将阻塞主线程


Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void saveDefaultConfig(){
FileOutputStream fileOutputStream = new FileOutputStream(new File(getDataFolder(), "config.yml"));
) {
byte[] bytes = new byte[resource.available()];
if(bytes.length==0) return;
int length = 0;
while ((length = resource.read(bytes))!=-1){
fileOutputStream.write(bytes,0,length);
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/com/meteor/wechatbc/impl/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public PluginManager(WeChatClient weChatClient){
if(!pluginsFolder.exists()){
pluginsFolder.mkdirs();
}
PluginLoader.logger.info("开始载入插件");
for (File pluginFile : pluginsFolder.listFiles()) {
if(pluginFile.isFile()){
this.loadPlugin(pluginFile);
Expand Down Expand Up @@ -60,6 +61,10 @@ public void loadPlugin(File file){
PluginLoader.logger.info("插件 [{}] 已存在,无法重新加载",pluginDescription.getName());
return;
}


PluginLoader.logger.info("正在载入插件{}",pluginDescription.getName());

URL[] urls = new URL[0];
try {
urls = new URL[]{ file.toURI().toURL() };
Expand All @@ -78,26 +83,19 @@ public void loadPlugin(File file){
// 解析指令并创建实例
pluginDescription.getCommands().forEach(mainCommand->{
WeChatCommand weChatCommand = new WeChatCommand(mainCommand);
PluginLoader.logger.info(" 解析指令 {}",weChatCommand.getMainCommand());
weChatClient.getCommandManager().registerCommand(weChatCommand);
});
}
pluginMap.put(pluginDescription.getName(),plugin);
// 初始化插件
PluginLoader.logger.info(" 初始化 {}",pluginDescription.getMain());
plugin.init(pluginDescription,weChatClient);
// 调用插件启动hook
plugin.onEnable();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
PluginLoader.logger.info("已载入 {}",pluginDescription.getName());
} catch (Exception e){
e.printStackTrace();
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/meteor/wechatbc/util/VersionCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class VersionCheck {

private static final String CURRENT_VERSION = "v1.1.1";
private static final String CURRENT_VERSION = "v1.1.2";

public static void check(String owner, String repo) {

Expand Down

0 comments on commit 2169210

Please sign in to comment.