Skip to content

Commit

Permalink
feat: add support for legacy spigot 1.8 - 1.12 (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 authored Jan 25, 2025
1 parent 414cda8 commit 2bdeb5b
Show file tree
Hide file tree
Showing 32 changed files with 2,848 additions and 228 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,27 @@ jobs:
strategy:
fail-fast: false
matrix:
release-task: [curseforge, discordupload, modrinth]
include:
# Java 8 for legacyspigot
- project: legacyspigot
java-version: 8
release-task: curseforge
- project: legacyspigot
java-version: 8
release-task: discordupload
- project: legacyspigot
java-version: 8
release-task: modrinth
# Java 16 for spigot
- project: spigot
java-version: 16
release-task: curseforge
- project: spigot
java-version: 16
release-task: discordupload
- project: spigot
java-version: 16
release-task: modrinth
needs: release-please
runs-on: ubuntu-latest
environment: release
Expand All @@ -39,11 +59,11 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Set up JDK 16
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 16
distribution: temurin
java-version: ${{ matrix.java-version }}
- name: Build and publish (release)
env:
CURSE_API: ${{ secrets.CURSE_API }}
Expand All @@ -53,4 +73,4 @@ jobs:
IS_RELEASE: true
run: |
# Build
./gradlew build ${{ matrix.release-task }}
./gradlew build ${{ matrix.project }}:${{ matrix.release-task }}
21 changes: 10 additions & 11 deletions .github/workflows/snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,31 @@ on:
name: Build
jobs:
snapshot:
#if: ${{!startsWith(github.ref.split(’/’)[2], 'release-please')}}
runs-on: ubuntu-latest
# https://github.com/google-github-actions/release-please-action in case more config is needed
strategy:
matrix:
include:
- project: spigot
java-version: 16
- project: legacyspigot
java-version: 8
steps:
- uses: actions/checkout@v3
# these if statements ensure that a publication only occurs when
# a new release is created:
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Set up JDK 16
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 16
# - name: Download MC assets
# run: ./gradlew downloadAssets --info --debug || ./gradlew downloadAssets --info --debug || (sleep 30s && ./gradlew downloadAssets --info --debug)
# - name: Run DataGen
# run: ./gradlew runData
java-version: ${{ matrix.java-version }}
- name: Build and upload preview (run for non-release builds)
if: ${{ github.ref && !contains( github.ref, 'renovate/deps') }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
# Build
./gradlew build discordupload
./gradlew ${{ matrix.project }}:discordupload
7 changes: 0 additions & 7 deletions DragAndDropStarter.bat

This file was deleted.

166 changes: 3 additions & 163 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ buildscript {
}
}


plugins {
id "com.modrinth.minotaur" version "2.+"
id 'dev.s7a.gradle.minecraft.server' version '1.1.0'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
}

Expand Down Expand Up @@ -67,7 +64,6 @@ println("Snapshot Name: ${ext.snapshotName}")
println("Github SHA: ${ext.githubSha}")
println("Sha Ref: ${ext.shaRef}")

archivesBaseName = "Advanced-Portals"
group = 'com.sekwah.advancedportals'
println "Version: ${getVersion()}"

Expand All @@ -85,174 +81,18 @@ repositories {
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
}

// includeLibs just says to include the library in the final jar
dependencies {
includeLibs project(':lang')
includeLibs project(':core')
includeLibs project(':bungee')
includeLibs project(':spigot')
includeLibs project(':velocity')
}
// Needed to find generateTemplates task
evaluationDependsOn(':core')

println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"

tasks.named('jar') {
dependsOn(':core:shadowJar')
}

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)
}

}

// 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"]
}

tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.WARN
}

/**
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
*/
tasks.register('copyPlugin') {
dependsOn(build)
doLast {
copy {
def sourceFilePath = Paths.get("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
def destinationFilePath = Paths.get("$buildDir/MinecraftServer/plugins/Advanced-Portals.jar")

println "Handling file: $destinationFilePath"

byte[] newContent = Files.readAllBytes(sourceFilePath)

if (Files.exists(destinationFilePath)) {
println "File exists. Overwriting with new binary content."

Files.write(destinationFilePath, newContent, StandardOpenOption.TRUNCATE_EXISTING)
} else {
println "File does not exist. Copying from source."

Files.copy(sourceFilePath, destinationFilePath, StandardCopyOption.REPLACE_EXISTING)
}
}
}
}

// 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
tasks.register('runJar') {
doLast {
javaexec {
main "-jar"
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
workingDir "${System.env.MC_SERVER_LOC}"
}
}
}


idea {
project {
settings {
taskTriggers {
afterSync(project(':core').tasks.named('generateTemplates'))
afterSync(project(':core').tasks.named('generateTemplates').get())
}
}
}
}

modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinth_slug
versionType = "release"
uploadFile = jar
loaders = ["spigot", "bukkit", "paper", "velocity", "waterfall", "bungeecord", "purpur"]
gameVersions = [
"1.13",
"1.13.1",
"1.13.2",
"1.14",
"1.14.1",
"1.14.2",
"1.14.3",
"1.14.4",
"1.15",
"1.15.1",
"1.15.2",
"1.16",
"1.16.1",
"1.16.2",
"1.16.3",
"1.16.4",
"1.16.5",
"1.17",
"1.17.1",
"1.18",
"1.18.1",
"1.18.2",
"1.19",
"1.19.1",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",
"1.20.3",
"1.20.4",
"1.20.5",
"1.20.6",
"1.21",
"1.21.1",
"1.21.2",
"1.21.3",
"1.21.4"
]
changelog = getReleaseChangelog()
syncBodyFrom = rootProject.file("README.md").text
}

tasks.modrinth.dependsOn(tasks.modrinthSyncBody)


apply from: 'curse.gradle'
apply from: 'discord.gradle'
2 changes: 1 addition & 1 deletion changelog-util.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext.getReleaseChangelog = {
def changelogFile = file('CHANGELOG.md')
def changelogFile = rootProject.file('CHANGELOG.md')
def changelog = "## [${changelogFile.text.split('\n## \\[')[1]}\n\n" // ${project.github}/blob/${branch}/CHANGELOG.md
return changelog
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ public class ShowDestiSubCommand

@Override
public void onCommand(CommandSenderContainer sender, String[] args) {
if (core.getMcVersion()[1] < 16) {
sender.sendMessage(
Lang.getNegativePrefix()
+ Lang.translate("command.portal.show.unsupported"));
return;
}

PlayerData tempData =
tempDataServices.getPlayerData(sender.getPlayerContainer());
if (tempData.isDestiVisible()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ public class ShowPortalSubCommand

@Override
public void onCommand(CommandSenderContainer sender, String[] args) {
if (core.getMcVersion()[1] < 16) {
sender.sendMessage(
Lang.getNegativePrefix()
+ Lang.translate("command.portal.show.unsupported"));
return;
}

PlayerData tempData =
playerDataServices.getPlayerData(sender.getPlayerContainer());
if (tempData.isPortalVisible()) {
Expand Down
33 changes: 9 additions & 24 deletions curse.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}
}

apply from: 'env-variables.gradle'
apply from: rootProject.file('env-variables.gradle')

static String getValueFromCurseAPI(apiKey, endpoint) {
String API_BASE_URL = 'https://minecraft.curseforge.com'
Expand Down Expand Up @@ -108,9 +108,13 @@ class UploadResponse {
int id
}

ext {
supportedVersions = []
}

// Based on https://github.com/matthewprenger/CurseGradle as it didnt support Bukkit uploads at the time.
task curseforge {
group = 'distribute'
dependsOn(jar)
doLast {
String apiKey = System.getenv("CURSE_API")
Expand All @@ -129,29 +133,10 @@ task curseforge {
GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class)
def versions = gameVersions.findAll {it.gameVersionTypeID == gameVersionTypeID}

String[] supportedVersions = [
"1.21",
"1.20.6",
"1.20.5",
"1.20.4",
"1.20.3",
"1.20.2",
"1.20.1",
"1.20",
"1.19.4",
"1.19.3",
"1.19.2",
"1.19.1",
"1.19",
"1.18.2",
"1.18.1",
"1.18",
"1.17",
"1.16",
"1.15",
"1.14",
"1.13"
]
if (supportedVersions.isEmpty()) {
println("No supported versions specified. Please set 'supportedVersions' in the applying file.")
return
}

def supportedGameVersions = versions.findAll {supportedVersions.contains(it.name)}
int[] supportedGameVersionIds = supportedGameVersions.collect {it.id}.toArray()
Expand Down
Loading

0 comments on commit 2bdeb5b

Please sign in to comment.