2024-07-28 00:39:33 +02:00
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Paths
|
|
|
|
import java.nio.file.StandardCopyOption
|
|
|
|
import java.nio.file.StandardOpenOption
|
|
|
|
|
|
|
|
|
2022-05-04 02:17:54 +02:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
maven {url "https://plugins.gradle.org/m2/"}
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath "org.apache.httpcomponents:httpmime:4.5.13"
|
|
|
|
classpath "com.google.code.gson:gson:2.8.6"
|
|
|
|
classpath "org.apache.httpcomponents:httpclient:4.5.13"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'dev.s7a.gradle.minecraft.server' version '1.1.0'
|
2024-11-13 12:02:01 +01:00
|
|
|
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
|
2022-05-04 02:17:54 +02:00
|
|
|
}
|
|
|
|
|
2021-05-24 01:19:12 +02:00
|
|
|
allprojects {
|
|
|
|
apply plugin: 'java'
|
2024-11-13 12:02:01 +01:00
|
|
|
apply plugin: 'idea'
|
2021-05-24 01:19:12 +02:00
|
|
|
|
2024-05-12 14:36:37 +02:00
|
|
|
tasks.withType(JavaCompile).configureEach {
|
2021-05-25 02:32:22 +02:00
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
}
|
2021-05-24 01:19:12 +02:00
|
|
|
|
2023-11-22 01:25:22 +01:00
|
|
|
if (project.name != "Advanced-Portals") {
|
2022-04-24 04:30:26 +02:00
|
|
|
task buildSubmodules doLast {
|
|
|
|
task -> println "Building $task.project.name"
|
|
|
|
}
|
2022-04-24 04:31:39 +02:00
|
|
|
buildSubmodules.finalizedBy build
|
2022-04-24 04:30:26 +02:00
|
|
|
}
|
|
|
|
|
2024-05-18 02:33:12 +02:00
|
|
|
tasks.processResources {
|
|
|
|
def files = ["plugin.yml", "bungee.yml"]
|
|
|
|
filesMatching(files) {
|
|
|
|
expand(["pluginVersion": project.version])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-14 22:12:18 +02:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_16
|
|
|
|
targetCompatibility = JavaVersion.VERSION_16
|
2024-05-12 14:36:37 +02:00
|
|
|
|
2021-05-24 01:19:12 +02:00
|
|
|
}
|
2021-05-22 01:58:51 +02:00
|
|
|
|
2024-11-19 06:22:38 +01:00
|
|
|
|
2022-04-24 14:44:14 +02:00
|
|
|
apply from: 'env-variables.gradle'
|
|
|
|
|
2024-11-19 01:27:54 +01:00
|
|
|
|
|
|
|
println("Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'")
|
|
|
|
println("Snapshot Name: ${ext.snapshotName}")
|
|
|
|
println("Github SHA: ${ext.githubSha}")
|
|
|
|
println("Sha Ref: ${ext.shaRef}")
|
|
|
|
|
2021-05-22 01:58:51 +02:00
|
|
|
archivesBaseName = "Advanced-Portals"
|
2021-04-05 16:07:56 +02:00
|
|
|
group = 'com.sekwah.advancedportals'
|
2024-11-18 06:11:27 +01:00
|
|
|
def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '')
|
|
|
|
setVersion(versionString)
|
|
|
|
println "Version: ${getVersion()}"
|
2021-04-05 16:07:56 +02:00
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
description = ""
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
// configuration that holds jars to copy into lib
|
2022-04-24 04:34:45 +02:00
|
|
|
implementation.extendsFrom(includeLibs)
|
2018-07-23 02:43:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2020-01-20 11:55:18 +01:00
|
|
|
maven { url "https://repo.maven.apache.org/maven2" }
|
2018-07-23 02:43:29 +02:00
|
|
|
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
2020-01-20 11:55:18 +01:00
|
|
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
2020-12-30 03:49:45 +01:00
|
|
|
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
|
2019-01-29 11:49:43 +01:00
|
|
|
}
|
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
// includeLibs just says to include the library in the final jar
|
|
|
|
dependencies {
|
2024-11-18 06:11:27 +01:00
|
|
|
includeLibs project(':lang')
|
|
|
|
includeLibs project(':core')
|
|
|
|
includeLibs project(':bungee')
|
|
|
|
includeLibs project(':spigot')
|
|
|
|
includeLibs project(':velocity')
|
2018-07-23 02:43:29 +02:00
|
|
|
}
|
|
|
|
|
2024-11-18 06:11:27 +01:00
|
|
|
apply from: 'env-variables.gradle'
|
2021-04-05 15:47:34 +02:00
|
|
|
|
2024-11-18 06:11:27 +01:00
|
|
|
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
|
2021-04-05 15:47:34 +02:00
|
|
|
|
2024-11-19 06:22:38 +01:00
|
|
|
tasks.named('jar') {
|
|
|
|
dependsOn(':core:shadowJar')
|
|
|
|
}
|
2021-04-05 15:47:34 +02:00
|
|
|
|
2024-11-18 06:11:27 +01:00
|
|
|
jar {
|
|
|
|
// Filters the files out that are in the build folders. Look to see if there is a better way to do this?
|
|
|
|
from configurations.includeLibs.filter {
|
|
|
|
it.path.contains("${File.separator}build${File.separator}libs")
|
|
|
|
} .collect {
|
|
|
|
println("Will Include: ${it.name}")
|
|
|
|
it.isDirectory() ? it : zipTree(it)
|
2021-04-05 15:47:34 +02:00
|
|
|
}
|
2022-05-04 02:17:54 +02:00
|
|
|
|
|
|
|
}
|
2023-12-03 15:19:57 +01:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
2022-05-04 02:17:54 +02:00
|
|
|
minecraftServerConfig {
|
2023-11-22 01:23:23 +01:00
|
|
|
jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.20.2.jar')
|
2022-05-04 02:17:54 +02:00
|
|
|
jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
|
|
|
}
|
|
|
|
|
2024-05-12 14:36:37 +02:00
|
|
|
tasks.withType(Jar).configureEach {
|
2023-04-06 19:41:18 +02:00
|
|
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
|
|
|
}
|
2022-05-04 02:17:54 +02:00
|
|
|
|
2023-12-03 15:19:57 +01:00
|
|
|
/**
|
|
|
|
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
|
|
|
|
*/
|
2024-05-12 14:36:37 +02:00
|
|
|
tasks.register('copyPlugin') {
|
2023-12-03 15:19:57 +01:00
|
|
|
dependsOn(build)
|
2022-05-04 02:17:54 +02:00
|
|
|
doLast {
|
|
|
|
copy {
|
2024-05-25 04:12:55 +02:00
|
|
|
def sourceFilePath = Paths.get("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
|
|
|
|
def destinationFilePath = Paths.get("$buildDir/MinecraftServer/plugins/Advanced-Portals.jar")
|
|
|
|
|
|
|
|
println "Handling file: $destinationFilePath"
|
2024-06-16 04:32:49 +02:00
|
|
|
|
2024-05-25 04:12:55 +02:00
|
|
|
byte[] newContent = Files.readAllBytes(sourceFilePath)
|
2024-06-16 04:32:49 +02:00
|
|
|
|
2024-05-25 04:12:55 +02:00
|
|
|
if (Files.exists(destinationFilePath)) {
|
|
|
|
println "File exists. Overwriting with new binary content."
|
2024-06-16 04:32:49 +02:00
|
|
|
|
2024-05-25 04:12:55 +02:00
|
|
|
Files.write(destinationFilePath, newContent, StandardOpenOption.TRUNCATE_EXISTING)
|
|
|
|
} else {
|
|
|
|
println "File does not exist. Copying from source."
|
2024-06-16 04:32:49 +02:00
|
|
|
|
2024-05-25 04:12:55 +02:00
|
|
|
Files.copy(sourceFilePath, destinationFilePath, StandardCopyOption.REPLACE_EXISTING)
|
2022-05-04 02:17:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-05 15:47:34 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
|
|
|
|
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
2024-11-18 06:11:27 +01:00
|
|
|
tasks.register('runJar') {
|
2018-07-23 02:43:29 +02:00
|
|
|
doLast {
|
|
|
|
javaexec {
|
|
|
|
main "-jar"
|
|
|
|
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
|
2018-08-27 22:43:02 +02:00
|
|
|
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
2018-07-23 02:43:29 +02:00
|
|
|
workingDir "${System.env.MC_SERVER_LOC}"
|
|
|
|
}
|
|
|
|
}
|
2019-12-30 15:52:00 +01:00
|
|
|
}
|
2021-05-12 02:19:01 +02:00
|
|
|
|
2018-06-04 12:54:52 +02:00
|
|
|
|
2024-11-18 06:11:27 +01:00
|
|
|
idea {
|
|
|
|
project {
|
|
|
|
settings {
|
|
|
|
taskTriggers {
|
|
|
|
afterSync(project(':core').tasks.named('generateTemplates'))
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 05:47:35 +02:00
|
|
|
}
|
2018-06-07 00:00:58 +02:00
|
|
|
}
|
2024-11-19 01:27:54 +01:00
|
|
|
|
|
|
|
apply from: 'curse.gradle'
|
|
|
|
apply from: 'discord.gradle'
|