From 725b847caa06efdc6771551c07e3ef947f42cfb2 Mon Sep 17 00:00:00 2001 From: sekwah Date: Sun, 3 Dec 2023 14:19:57 +0000 Subject: [PATCH] chore: improve dev tasks --- build.gradle | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/build.gradle b/build.gradle index 38cf006..5314d24 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,36 @@ jar { } } + +// This is used to download my plugin for helping reload the server in tandem with the copyPlugin task +tasks.register('downloadSekCDevToolsPlugin') { + doLast { + // Define the URL and destination path + def url = 'https://github.com/sekwah41/SekCDevToolsPlugin/releases/download/v1.0.0/SekCDevToolsPlugin-1.0-SNAPSHOT.jar' + def destinationDir = new File("$buildDir/MinecraftServer/plugins") + def destinationFile = new File(destinationDir, 'SekCDevToolsPlugin-1.0-SNAPSHOT.jar') + + // Create the directory if it doesn't exist + if (!destinationDir.exists()) { + destinationDir.mkdirs() + } + + // Download the file if it doesn't exist + if (!destinationFile.exists()) { + println "Downloading SekCDevToolsPlugin..." + new URL(url).withInputStream { i -> + destinationFile.withOutputStream { + it << i + } + } + } else { + println "SekCDevToolsPlugin already downloaded" + } + } +} + +tasks.launchMinecraftServer.dependsOn(downloadSekCDevToolsPlugin) + minecraftServerConfig { jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.20.2.jar') jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"] @@ -93,7 +123,11 @@ tasks.withType(Jar) { duplicatesStrategy = DuplicatesStrategy.WARN } +/** + * Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin + */ task copyPlugin() { + dependsOn(build) doLast { copy { println "$buildDir/libs/Advanced-Portals-${getVersion()}.jar"