feat: 初步添加BC分组发送

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-12-10 18:05:55 +08:00
parent 938bc2d03a
commit f806fdad0e
3 changed files with 16 additions and 2 deletions

View File

@ -1,14 +1,19 @@
package pw.yumc.MiaoChat; 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.config.ServerInfo;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import pw.yumc.MiaoChat.bungee.FileConfig;
import java.net.InetSocketAddress;
public class MiaoChatBungee extends Plugin implements Listener { public class MiaoChatBungee extends Plugin implements Listener {
private Map<InetSocketAddress, List<ServerInfo>> group;
private FileConfig config;
@EventHandler @EventHandler
public void handle(final PluginMessageEvent event) { public void handle(final PluginMessageEvent event) {
if (event.getTag().equals(MiaoMessage.CHANNEL) || event.getTag().equals(MiaoMessage.NORMALCHANNEL)) { 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 @Override
public void onEnable() { public void onEnable() {
getProxy().registerChannel(MiaoMessage.CHANNEL); getProxy().registerChannel(MiaoMessage.CHANNEL);

View File

@ -2,6 +2,7 @@ package pw.yumc.MiaoChat.bungee;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -169,6 +170,9 @@ public class FileConfig {
public FileConfig(Plugin plugin, String name) { public FileConfig(Plugin plugin, String name) {
this.file = new File(plugin.getDataFolder(), name); this.file = new File(plugin.getDataFolder(), name);
try { try {
if (!file.exists()) {
Files.copy(plugin.getResourceAsStream(name), file.toPath());
}
this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file); this.config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) { } catch (IOException e) {
Log.w("配置文件读取失败!"); Log.w("配置文件读取失败!");

View File