forked from circlecloud/MiaoChat
feat: compatible 1.18
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
4da0b92f3f
commit
45ec56bebe
5
pom.xml
5
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>MiaoChat</artifactId>
|
||||
<version>1.9.3</version>
|
||||
<version>1.9.5</version>
|
||||
|
||||
<parent>
|
||||
<groupId>pw.yumc</groupId>
|
||||
@ -13,8 +13,9 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<update.description>§a正式版本 §bv1.9.3 §b兼容 1.17 版本</update.description>
|
||||
<update.description>§a正式版本 §bv1.9.5 §b兼容 1.15 版本</update.description>
|
||||
<update.changes>
|
||||
§621-06-20 §a增强: 兼容 1.18 版本 兼容新版PAPI;
|
||||
§621-06-20 §a增强: 兼容 1.17 版本;
|
||||
§620-10-10 §c修复: 1.16.3聊天包格式调整的问题;
|
||||
§620-04-10 §c修复: L10N 本地化组件报错的问题;
|
||||
|
@ -1,5 +1,9 @@
|
||||
package pw.yumc.MiaoChat;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,12 +15,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderHook;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import pw.yumc.MiaoChat.config.ChatConfig;
|
||||
import pw.yumc.MiaoChat.listeners.ChatListener;
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
@ -32,6 +31,7 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
|
||||
private FileConfig cfg;
|
||||
private ChatConfig chatConfig;
|
||||
private String ServerName;
|
||||
private PlaceholderExpansion expansion;
|
||||
|
||||
public ChatConfig getChatConfig() {
|
||||
return chatConfig;
|
||||
@ -65,6 +65,11 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
|
||||
L10N.getName(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.expansion.unregister();
|
||||
}
|
||||
|
||||
private void enableBungeeCord() {
|
||||
if (getChatConfig().isBungeeCord()) {
|
||||
Log.i("已开启 BungeeCord 模式!");
|
||||
@ -79,10 +84,30 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
|
||||
}
|
||||
|
||||
private void hookPlaceholderAPI() {
|
||||
PlaceholderAPI.registerPlaceholderHook("mct", new PlaceholderHook() {
|
||||
this.expansion = new PlaceholderExpansion() {
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String s) {
|
||||
switch (s.toLowerCase()) {
|
||||
public @NotNull String getIdentifier() {
|
||||
return "mct";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "MiaoWoo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, @NotNull String params) {
|
||||
switch (params.toLowerCase()) {
|
||||
case "server":
|
||||
return getChatConfig().getServername();
|
||||
case "bserver":
|
||||
@ -91,7 +116,8 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
|
||||
}
|
||||
return "未知的参数";
|
||||
}
|
||||
});
|
||||
};
|
||||
this.expansion.register();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,11 +1,5 @@
|
||||
package pw.yumc.MiaoChat;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
@ -17,6 +11,12 @@ import net.md_5.bungee.event.EventHandler;
|
||||
import pw.yumc.MiaoChat.bungee.FileConfig;
|
||||
import pw.yumc.MiaoChat.bungee.Log;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author MiaoWoo
|
||||
*/
|
||||
@ -49,21 +49,20 @@ public class MiaoChatBungee extends Plugin implements Listener {
|
||||
Map<String, ServerInfo> temp = getProxy().getServers();
|
||||
Set<ServerInfo> unused = new HashSet<>(temp.values());
|
||||
Configuration groupSel = config.getSection("Groups");
|
||||
// 读取所有的分组名称
|
||||
groupSel.getKeys().forEach(groupName -> {
|
||||
// 获取每个分组的服务器名称
|
||||
Set<String> servers = new HashSet<>(groupSel.getStringList(groupName));
|
||||
// 新建当前分组数组
|
||||
Set<ServerInfo> serverInfos = new HashSet<>();
|
||||
servers.forEach(s -> {
|
||||
if (temp.containsKey(s)) {
|
||||
ServerInfo serverInfo = temp.get(s);
|
||||
unused.remove(serverInfo);
|
||||
servers.forEach(ss -> {
|
||||
if (temp.containsKey(ss) && !ss.equals(s)) {
|
||||
serverInfos.add(temp.get(ss));
|
||||
}
|
||||
});
|
||||
groups.put(serverInfo.getAddress(), serverInfos);
|
||||
ServerInfo info = temp.get(s);
|
||||
unused.remove(info);
|
||||
serverInfos.add(info);
|
||||
}
|
||||
});
|
||||
serverInfos.forEach(serverInfo -> groups.put(serverInfo.getAddress(), serverInfos));
|
||||
});
|
||||
unused.forEach(serverInfo -> groups.put(serverInfo.getAddress(), unused));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user