From e7a362d8277b3ece4ca0a9948e5df4d11c8a0308 Mon Sep 17 00:00:00 2001 From: coding Date: Tue, 17 Oct 2017 02:57:05 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E9=87=8D=E8=BD=BD?= =?UTF-8?q?=E6=97=B6=E5=8D=B8=E8=BD=BDMiaoScript=E6=89=80=E6=9C=89?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=92=8C=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/pw/yumc/MiaoScript/MiaoScript.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/pw/yumc/MiaoScript/MiaoScript.java b/src/main/java/pw/yumc/MiaoScript/MiaoScript.java index 0b00809..bc134ab 100644 --- a/src/main/java/pw/yumc/MiaoScript/MiaoScript.java +++ b/src/main/java/pw/yumc/MiaoScript/MiaoScript.java @@ -1,16 +1,18 @@ package pw.yumc.MiaoScript; import java.io.File; -import java.io.FileReader; import java.io.InputStreamReader; import javax.script.ScriptEngineManager; import javax.script.ScriptException; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import lombok.SneakyThrows; +import lombok.val; import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.bukkit.P; import pw.yumc.YumCore.commands.CommandSub; @@ -53,6 +55,16 @@ public class MiaoScript extends JavaPlugin implements Executor { @Help("重启脚本引擎") public void reload(CommandSender sender) { disableEngine(); + val server = Bukkit.getServer(); + try { + server.getScheduler().cancelTasks(this); + server.getServicesManager().unregisterAll(this); + HandlerList.unregisterAll(this); + server.getMessenger().unregisterIncomingPluginChannel(this); + server.getMessenger().unregisterOutgoingPluginChannel(this); + } catch (Exception ex) { + Log.d("Error reload", ex); + } enableEngine(); Log.sender(sender, "§bMiaoScript §eEngine §a重启完成!"); }