2727@ Plugin (
2828 id = "hubcommand" ,
2929 name = "HubCommand" ,
30- version = "1.0.0 " ,
30+ version = "1.0.3 " ,
3131 authors = {"Hitech0926" }
3232)
3333public class HubCommand {
@@ -75,11 +75,26 @@ public ProxyServer getServer() {
7575 }
7676
7777 private void loadConfig () {
78+ if (!Files .exists (dataDirectory )) {
79+ try {
80+ Files .createDirectories (dataDirectory );
81+ } catch (IOException e ) {
82+ logger .error ("无法创建插件目录" , e );
83+ return ;
84+ }
85+ }
86+
7887 File file = dataDirectory .resolve ("config.yml" ).toFile ();
7988 Yaml yaml = new Yaml ();
8089 if (!file .exists ()) {
8190 try (InputStream inputStream = getClass ().getClassLoader ().getResourceAsStream ("config.yml" )) {
82- Files .copy (inputStream , file .toPath ());
91+ if (inputStream != null ) {
92+ Files .copy (inputStream , file .toPath ());
93+ logger .info ("配置文件已创建!" );
94+ } else {
95+ logger .error ("无法找到默认配置文件" );
96+ return ;
97+ }
8398 } catch (IOException e ) {
8499 logger .error ("无法创建配置文件" , e );
85100 return ;
@@ -92,6 +107,8 @@ private void loadConfig() {
92107 sendSuccessful = (String ) config .getOrDefault ("send-successful" , "<green>你已被传送到大厅!" );
93108 noPermission = (String ) config .getOrDefault ("no-permission" , "<red>你没有权限执行此命令!" );
94109 noConsole = (String ) config .getOrDefault ("no-console" , "<red>只有玩家可以执行此命令!" );
110+
111+ logger .info ("配置文件加载成功!" );
95112 } catch (IOException e ) {
96113 logger .error ("无法加载配置文件" , e );
97114 }
0 commit comments