Skip to content

Instantly share code, notes, and snippets.

@maityyy
Last active July 14, 2023 12:28
Show Gist options
  • Save maityyy/4604e9b4bd4ce91a8573171ea384d77d to your computer and use it in GitHub Desktop.
Save maityyy/4604e9b4bd4ce91a8573171ea384d77d to your computer and use it in GitHub Desktop.
Paper NMS dependency in gradle
import java.nio.channels.Channels
def paper = { String version ->
String paperPath = this.gradle.getGradleHomeDir().getAbsolutePath() + "\\papers\\paper-${version}.jar"
File paper = new File(paperPath)
if (paper.parentFile != null || !paper.parentFile.exists()) {
paper.parentFile.mkdir()
}
if (!paper.exists()) {
URLConnection url = new URL("https://yivesmirror.com/files/paper/Paper-${version}.jar").openConnection()
// Fixes HTTP 403 connection issues and allows download large files
url.setRequestProperty("User-Agent", "Mozilla")
url.setConnectTimeout(Integer.MAX_VALUE)
FileOutputStream outputStream = new FileOutputStream(paperPath)
// noinspection UnnecessaryQualifiedReference
outputStream.getChannel().transferFrom(java.nio.channels.Channels.newChannel(url.inputStream), 0, Long.MAX_VALUE)
outputStream.close()
}
return paperPath
}
dependencies {
// "[GAME VERSION]-b[BUILD NUMBER]" or "[GAME VERSION]-latest" for latest build
implementation files(paper('1.16.3-b196'))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment