diff --git a/pom.xml b/pom.xml index 05fb31d..f87ae16 100644 --- a/pom.xml +++ b/pom.xml @@ -13,14 +13,6 @@ - - maven-compiler-plugin - 3.3 - - 1.7 - 1.7 - - org.apache.maven.plugins maven-shade-plugin @@ -78,16 +70,12 @@ http://ci.yumc.pw/job/${project.artifactId}/ - - - DEBUG + DEV UTF-8 + 1.7 + 1.7 - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - yumc-repo http://repo.yumc.pw/content/groups/public/ diff --git a/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java b/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java index 4887e3e..fd3f6ed 100644 --- a/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java +++ b/src/main/java/pw/yumc/MiaoChat/MiaoChatBungee.java @@ -1,19 +1,22 @@ package pw.yumc.MiaoChat; import java.net.InetSocketAddress; -import java.util.List; -import java.util.Map; +import java.util.*; +import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; import net.md_5.bungee.event.EventHandler; import pw.yumc.MiaoChat.bungee.FileConfig; public class MiaoChatBungee extends Plugin implements Listener { - private Map> group; + private Map> groups; private FileConfig config; + @EventHandler public void handle(final PluginMessageEvent event) { if (event.getTag().equals(MiaoMessage.CHANNEL) || event.getTag().equals(MiaoMessage.NORMALCHANNEL)) { @@ -31,11 +34,54 @@ public class MiaoChatBungee extends Plugin implements Listener { config = new FileConfig(this, "group.yml"); } + public void loadGroup() { + Map temp = new HashMap<>(); + Set unused = new HashSet<>(); + for (ServerInfo server : getProxy().getServers().values()) { + temp.put(server.getName(), server.getAddress()); + } + Configuration groupSel = config.getSection("Groups"); + Collection groupname = groupSel.getKeys(); + for (String gname : groupname) { + Set servers = new HashSet<>(groupSel.getStringList(gname)); + Set serISA = new HashSet<>(); + for (String sname : servers) { + serISA.add(temp.get(sname)); + } + serISA.remove(null); + for (String sname : servers) { + InetSocketAddress isadd = temp.get(sname); + if (isadd != null) { + unused.remove(isadd); + groups.put(isadd, serISA); + } + } + } + for (InetSocketAddress unser : unused) { + groups.put(unser, unused); + } + } + @Override public void onEnable() { getProxy().registerChannel(MiaoMessage.CHANNEL); getProxy().registerChannel(MiaoMessage.NORMALCHANNEL); getProxy().getPluginManager().registerListener(this, this); + getProxy().getPluginManager().registerCommand(this, new Command("MiaoChat", "MiaoChat.admin", "mct") { + @Override + public void execute(CommandSender commandSender, String[] args) { + if (args.length > 1) { + switch (args[0].toLowerCase()) { + case "reload": + onLoad(); + break; + case "version": + commandSender.sendMessage(getDescription().getVersion()); + break; + } + } + } + }); getLogger().info("注意: 通过BC转发的聊天信息将不会在控制台显示 仅客户端可见!"); } } diff --git a/src/main/resources/group.yml b/src/main/resources/group.yml index e69de29..95982d5 100644 --- a/src/main/resources/group.yml +++ b/src/main/resources/group.yml @@ -0,0 +1,15 @@ +#配置版本号 请勿修改 +Version: 1.0 + +#跨服分组 +#注: 未在分组内的服务器会被分配到独立的一组 +#注: 内部分组名称为 ungroup 下方如有定义将无效 +Groups: + #普通分组 + normal: + - 'sc1' + - 'sc2' + #游戏分组 + games: + - 'bw1' + - 'sg1' \ No newline at end of file