From 2e7f755f81e4b77b7605459a363ee8fe9abc4c97 Mon Sep 17 00:00:00 2001 From: PonderFox0643 Date: Mon, 6 Oct 2025 03:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=9B=E5=BB=BA=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../com/hitech0926/hubcommand/HubCommand.java | 21 +++++++++++++++++-- src/main/resources/velocity-plugin.json | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index b517eee..60a3963 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.hitech0926 HubCommand - 1.0.2 + 1.0.3 8 diff --git a/src/main/java/com/hitech0926/hubcommand/HubCommand.java b/src/main/java/com/hitech0926/hubcommand/HubCommand.java index a3a4d7f..b63922c 100644 --- a/src/main/java/com/hitech0926/hubcommand/HubCommand.java +++ b/src/main/java/com/hitech0926/hubcommand/HubCommand.java @@ -27,7 +27,7 @@ @Plugin( id = "hubcommand", name = "HubCommand", - version = "1.0.0", + version = "1.0.3", authors = {"Hitech0926"} ) public class HubCommand { @@ -75,11 +75,26 @@ public ProxyServer getServer() { } private void loadConfig() { + if (!Files.exists(dataDirectory)) { + try { + Files.createDirectories(dataDirectory); + } catch (IOException e) { + logger.error("无法创建插件目录", e); + return; + } + } + File file = dataDirectory.resolve("config.yml").toFile(); Yaml yaml = new Yaml(); if (!file.exists()) { try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("config.yml")) { - Files.copy(inputStream, file.toPath()); + if (inputStream != null) { + Files.copy(inputStream, file.toPath()); + logger.info("配置文件已创建!"); + } else { + logger.error("无法找到默认配置文件"); + return; + } } catch (IOException e) { logger.error("无法创建配置文件", e); return; @@ -92,6 +107,8 @@ private void loadConfig() { sendSuccessful = (String) config.getOrDefault("send-successful", "你已被传送到大厅!"); noPermission = (String) config.getOrDefault("no-permission", "你没有权限执行此命令!"); noConsole = (String) config.getOrDefault("no-console", "只有玩家可以执行此命令!"); + + logger.info("配置文件加载成功!"); } catch (IOException e) { logger.error("无法加载配置文件", e); } diff --git a/src/main/resources/velocity-plugin.json b/src/main/resources/velocity-plugin.json index 7f1a61c..9745f2b 100644 --- a/src/main/resources/velocity-plugin.json +++ b/src/main/resources/velocity-plugin.json @@ -1 +1 @@ -{"id":"hubcommand","name":"HubCommand","version":"1.0.2","authors":["HitTech0926"],"dependencies":[],"main":"com.hitech0926.hubcommand.HubCommand"} \ No newline at end of file +{"id":"hubcommand","name":"HubCommand","version":"1.0.3","authors":["HitTech0926"],"dependencies":[],"main":"com.hitech0926.hubcommand.HubCommand"} \ No newline at end of file