From 6eddc99b02a656db4c98ae0ccb8f98901c4be0ee Mon Sep 17 00:00:00 2001 From: MiniDay <372403923@qq.com> Date: Mon, 7 Nov 2022 00:33:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/plugin/ball/server/config/ServerConfig.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hamster-ball-server/src/main/java/cn/hamster3/mc/plugin/ball/server/config/ServerConfig.java b/hamster-ball-server/src/main/java/cn/hamster3/mc/plugin/ball/server/config/ServerConfig.java index 521e069..da56c0a 100644 --- a/hamster-ball-server/src/main/java/cn/hamster3/mc/plugin/ball/server/config/ServerConfig.java +++ b/hamster-ball-server/src/main/java/cn/hamster3/mc/plugin/ball/server/config/ServerConfig.java @@ -26,9 +26,10 @@ public final class ServerConfig { @SuppressWarnings("unchecked") public static void init() throws IOException { File configFile = new File("config.yml"); - InputStream stream = Files.newInputStream(configFile.toPath()); - Map map = new Yaml().load(stream); - stream.close(); + Map map; + try (InputStream stream = Files.newInputStream(configFile.toPath())) { + map = new Yaml().load(stream); + } host = (String) map.get("host"); port = (int) map.get("port");