diff --git a/build.gradle b/build.gradle index 6229959..923eee5 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,8 @@ plugins { } group 'tk.smileyik' -version '1.4' +version '1.5' +archivesBaseName = 'LuaInMinecraftBukkit' repositories { maven { @@ -31,9 +32,20 @@ test { useJUnitPlatform() } +// 删除plugins文件夹中以前构建的文件. +task deleteOldBuilds(type: Delete) { + for (final def f in file("${projectDir}/server/plugins/").listFiles()) { + if (f.isFile() && f.getName().startsWith("${archivesBaseName}")) { + printf("Remove old build: %s\n", f.toString()) + delete f + } + } +} + +// 复制当前版本到plugins文件夹中 task copyTask(type: Copy) { dependsOn(build) - from "${buildDir}/libs/LuaInMinecraftBukkit-1.4.jar" - println "${projectDir}/server/plugins/LuaInMinecraftBukkit-1.4.jar" + dependsOn(deleteOldBuilds) + from "${buildDir}/libs/${archivesBaseName}-${version}.jar" into "${projectDir}/server/plugins/" } \ No newline at end of file diff --git a/src/main/java/tk/smileyik/luainminecraftbukkit/PluginSetting.java b/src/main/java/tk/smileyik/luainminecraftbukkit/PluginSetting.java index 4d4bd2e..995033d 100644 --- a/src/main/java/tk/smileyik/luainminecraftbukkit/PluginSetting.java +++ b/src/main/java/tk/smileyik/luainminecraftbukkit/PluginSetting.java @@ -1,6 +1,6 @@ package tk.smileyik.luainminecraftbukkit; -import tk.smileyik.luainminecraftbukkit.luaplugin.util.NativeLuaLoader; +import tk.smileyik.luainminecraftbukkit.util.NativeLuaLoader; import java.io.IOException; diff --git a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/command/CommandRegister.java b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/command/CommandRegister.java index d8861ea..5d0ee98 100644 --- a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/command/CommandRegister.java +++ b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/command/CommandRegister.java @@ -28,7 +28,8 @@ public void registerCommand(String command, String id) { * @param label 指令. * @param args 指令. */ - public void dispatch(CommandSender sender, Command command, String label, String[] args) { + public void dispatch(CommandSender sender, + Command command, String label, String[] args) { if (args.length >= 1) { label = args[0]; if (commandMapper.containsKey(label)) { diff --git a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/event/LuaEvent.java b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/event/LuaEvent.java index c99c3d5..e92138d 100644 --- a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/event/LuaEvent.java +++ b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/event/LuaEvent.java @@ -27,7 +27,8 @@ public LuaEvent(String id) { public void event(T e) { try { if (closure != null) { - LuaInMinecraftBukkit.getPluginManager().callClosure(vars[0], closure, e); + LuaInMinecraftBukkit.getPluginManager() + .callClosure(vars[0], closure, e); } else { LuaInMinecraftBukkit.getPluginManager().callClosure(vars, e); } diff --git a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/exception/LuaFunctionNotFountException.java b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/exception/LuaFunctionNotFountException.java index cadc4cd..16e09ea 100644 --- a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/exception/LuaFunctionNotFountException.java +++ b/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/exception/LuaFunctionNotFountException.java @@ -8,7 +8,8 @@ public LuaFunctionNotFountException(String pluginId, String path) { )); } - public LuaFunctionNotFountException(String pluginId, String path, Exception e) { + public LuaFunctionNotFountException(String pluginId, + String path, Exception e) { super(String.format( "脚本插件%s中未发现方法%s", pluginId, path diff --git a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/util/NativeLuaLoader.java b/src/main/java/tk/smileyik/luainminecraftbukkit/util/NativeLuaLoader.java similarity index 89% rename from src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/util/NativeLuaLoader.java rename to src/main/java/tk/smileyik/luainminecraftbukkit/util/NativeLuaLoader.java index d0f8d2f..4fbac22 100644 --- a/src/main/java/tk/smileyik/luainminecraftbukkit/luaplugin/util/NativeLuaLoader.java +++ b/src/main/java/tk/smileyik/luainminecraftbukkit/util/NativeLuaLoader.java @@ -1,4 +1,4 @@ -package tk.smileyik.luainminecraftbukkit.luaplugin.util; +package tk.smileyik.luainminecraftbukkit.util; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -81,9 +81,13 @@ public static void initNativeLua(File baseDir) throws IOException { } private static void storeLib(String from, File to) throws IOException { - try (BufferedInputStream bis = - new BufferedInputStream(Objects.requireNonNull(NativeLuaLoader.class.getResourceAsStream(from))); - BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(to.toPath()))) { + try ( + BufferedInputStream bis = + new BufferedInputStream(Objects.requireNonNull( + NativeLuaLoader.class.getResourceAsStream(from))); + BufferedOutputStream bos = + new BufferedOutputStream( + Files.newOutputStream(to.toPath()))) { byte[] bytes = new byte[8192]; int len; while ((len = bis.read(bytes)) != -1) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index bb867aa..5d5a4d7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: LuaInMinecraftBukkit main: tk.smileyik.luainminecraftbukkit.LuaInMinecraftBukkit -version: 1.4 +version: 1.5 api-version: 1.13 author: SmileYik commands: diff --git a/src/test/java/tk/smileyik/NativeTest1.java b/src/test/java/tk/smileyik/NativeTest1.java index c55d109..9dd5c6d 100644 --- a/src/test/java/tk/smileyik/NativeTest1.java +++ b/src/test/java/tk/smileyik/NativeTest1.java @@ -3,7 +3,7 @@ import org.keplerproject.luajava.LuaException; import org.keplerproject.luajava.LuaState; import org.keplerproject.luajava.LuaStateFactory; -import tk.smileyik.luainminecraftbukkit.luaplugin.util.NativeLuaLoader; +import tk.smileyik.luainminecraftbukkit.util.NativeLuaLoader; import java.io.File; import java.io.IOException; diff --git a/src/test/java/tk/smileyik/config/Test.java b/src/test/java/tk/smileyik/config/Test.java index bd39610..c92b0bf 100644 --- a/src/test/java/tk/smileyik/config/Test.java +++ b/src/test/java/tk/smileyik/config/Test.java @@ -2,7 +2,7 @@ import org.keplerproject.luajava.LuaException; import tk.smileyik.luainminecraftbukkit.api.luaconfig.LuaConfig; -import tk.smileyik.luainminecraftbukkit.luaplugin.util.NativeLuaLoader; +import tk.smileyik.luainminecraftbukkit.util.NativeLuaLoader; import java.io.File; import java.io.IOException;