From f806fdad0e2441ba7dbabd1c70cd4755a237097a Mon Sep 17 00:00:00 2001 From: 502647092 Date: Sat, 10 Dec 2016 18:05:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E6=AD=A5=E6=B7=BB=E5=8A=A0BC?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java | 14 ++++++++++++-- .../java/pw/yumc/MiaoChat/bungee/FileConfig.java | 4 ++++ src/main/resources/group.yml | 0 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/group.yml diff --git a/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java b/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java index 589f3fc..4887e3e 100644 --- a/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java +++ b/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java @@ -1,14 +1,19 @@ package pw.yumc.MiaoChat; +import java.net.InetSocketAddress; +import java.util.List; +import java.util.Map; + import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; - -import java.net.InetSocketAddress; +import pw.yumc.MiaoChat.bungee.FileConfig; public class MiaoChatBungee extends Plugin implements Listener { + private Map> group; + private FileConfig config; @EventHandler public void handle(final PluginMessageEvent event) { if (event.getTag().equals(MiaoMessage.CHANNEL) || event.getTag().equals(MiaoMessage.NORMALCHANNEL)) { @@ -21,6 +26,11 @@ public class MiaoChatBungee extends Plugin implements Listener { } } + @Override + public void onLoad() { + config = new FileConfig(this, "group.yml"); + } + @Override public void onEnable() { getProxy().registerChannel(MiaoMessage.CHANNEL); diff --git a/src/main/java/pw/yumc/MiaoChat/bungee/FileConfig.java b/src/main/java/pw/yumc/MiaoChat/bungee/FileConfig.java index fc0fc11..e29ed8d 100644 --- a/src/main/java/pw/yumc/MiaoChat/bungee/FileConfig.java +++ b/src/main/java/pw/yumc/MiaoChat/bungee/FileConfig.java @@ -2,6 +2,7 @@ package pw.yumc.MiaoChat.bungee; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.Collection; import java.util.List; @@ -169,6 +170,9 @@ public class FileConfig { public FileConfig(Plugin plugin, String name) { this.file = new File(plugin.getDataFolder(), name); try { + if (!file.exists()) { + Files.copy(plugin.getResourceAsStream(name), file.toPath()); + } this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file); } catch (IOException e) { Log.w("配置文件读取失败!"); diff --git a/src/main/resources/group.yml b/src/main/resources/group.yml new file mode 100644 index 0000000..e69de29