mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Use run-paper for bukkit runServer task
This commit is contained in:
1 parent
bdced0904b
commit
473daacd8d
2 files changed
+6
-37
No files matched your search
+4
-36
@@ -1,12 +1,9 @@
|
|||||||
import com.google.gson.JsonParser
|
|
||||||
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription.Permission.Default.TRUE
|
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription.Permission.Default.TRUE
|
||||||
import java.io.InputStreamReader
|
|
||||||
import java.net.URL
|
|
||||||
import java.time.Duration
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.johnrengelman.shadow")
|
id("com.github.johnrengelman.shadow")
|
||||||
id("net.minecrell.plugin-yml.bukkit")
|
id("net.minecrell.plugin-yml.bukkit")
|
||||||
|
id("xyz.jpenilla.run-paper")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -37,38 +34,9 @@ tasks {
|
|||||||
relocateDependency("io.papermc.lib")
|
relocateDependency("io.papermc.lib")
|
||||||
relocateDependency("io.leangen.geantyref")
|
relocateDependency("io.leangen.geantyref")
|
||||||
}
|
}
|
||||||
register<JavaExec>("runServer") {
|
runServer {
|
||||||
workingDir = projectDir.resolve("run")
|
minecraftVersion("1.16.5")
|
||||||
standardInput = System.`in`
|
pluginJarName("carbon.jar")
|
||||||
dependsOn(shadowJar)
|
|
||||||
val paperJar = workingDir.resolve("paperclip.jar")
|
|
||||||
classpath(paperJar)
|
|
||||||
args = listOf("nogui")
|
|
||||||
systemProperty("disable.watchdog", true)
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
// Create working dir and plugins dir if needed
|
|
||||||
if (!workingDir.exists()) workingDir.mkdir()
|
|
||||||
val pluginsDir = workingDir.resolve("plugins")
|
|
||||||
if (!pluginsDir.exists()) pluginsDir.mkdir()
|
|
||||||
|
|
||||||
// Copy carbon jar
|
|
||||||
val carbonJar = pluginsDir.resolve("carbon.jar")
|
|
||||||
shadowJar.get().archiveFile.get().asFile.copyTo(carbonJar, overwrite = true)
|
|
||||||
|
|
||||||
// Download latest Paperclip if we don't have one or if it's older than 3 days
|
|
||||||
val paperVersion = "1.16.5"
|
|
||||||
if (!paperJar.exists() || paperJar.lastModified() < System.currentTimeMillis() - Duration.ofDays(3).toMillis()) {
|
|
||||||
val jsonParser = JsonParser()
|
|
||||||
logger.lifecycle("Fetching latest Paper {} builds...", paperVersion)
|
|
||||||
val builds = jsonParser.parse(InputStreamReader(URL("https://papermc.io/api/v2/projects/paper/versions/$paperVersion").openStream())).asJsonObject["builds"].asJsonArray
|
|
||||||
val latest = builds.last().asString
|
|
||||||
logger.lifecycle("Downloading Paper {} build {}...", paperVersion, latest)
|
|
||||||
val jarUrl = URL("https://papermc.io/api/v2/projects/paper/versions/$paperVersion/builds/$latest/downloads/paper-$paperVersion-$latest.jar")
|
|
||||||
paperJar.writeBytes(jarUrl.readBytes())
|
|
||||||
logger.lifecycle("Done downloading Paper {} build {}.", paperVersion, latest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ plugins:
|
|||||||
net.kyori.indra.git: *indra
|
net.kyori.indra.git: *indra
|
||||||
com.github.johnrengelman.shadow: 7.1.0-hexaoxide-SNAPSHOT # todo: temporary until shadow bumps jdependency for Record support
|
com.github.johnrengelman.shadow: 7.1.0-hexaoxide-SNAPSHOT # todo: temporary until shadow bumps jdependency for Record support
|
||||||
net.minecrell.plugin-yml.bukkit: 0.4.0
|
net.minecrell.plugin-yml.bukkit: 0.4.0
|
||||||
org.spongepowered.gradle.plugin: 1.0.3
|
org.spongepowered.gradle.plugin: 1.1.0
|
||||||
|
xyz.jpenilla.run-paper: 1.0.0-SNAPSHOT
|
||||||
|
|
||||||
versions:
|
versions:
|
||||||
adventure: 4.7.0
|
adventure: 4.7.0
|
||||||
|
|||||||
Reference in new issue
Block a user