From 616f499f919d59169f0174d0f6a0ca7eaf8f3c19 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Tue, 12 Apr 2022 23:55:21 +0800 Subject: [PATCH] fix: compile error Signed-off-by: MiaoWoo --- src/main/java/pw/yumc/YumCore/statistic/Statistics.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/pw/yumc/YumCore/statistic/Statistics.java b/src/main/java/pw/yumc/YumCore/statistic/Statistics.java index 993e104..6632d8a 100644 --- a/src/main/java/pw/yumc/YumCore/statistic/Statistics.java +++ b/src/main/java/pw/yumc/YumCore/statistic/Statistics.java @@ -17,6 +17,7 @@ import pw.yumc.YumCore.engine.MiaoScriptEngine; import javax.script.ScriptException; import java.io.*; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; @@ -234,7 +235,11 @@ public class Statistics { try { return Bukkit.getOnlinePlayers().size(); } catch (Exception ex) { - return ((Player[]) getOnlinePlayers.invoke(Bukkit.getServer())).length; + try { + return ((Player[]) getOnlinePlayers.invoke(Bukkit.getServer())).length; + } catch (IllegalAccessException | InvocationTargetException e) { + return 0; + } } }