Skip to content

Commit 6b51c1a

Browse files
committed
init
0 parents  commit 6b51c1a

File tree

16 files changed

+1266
-0
lines changed

16 files changed

+1266
-0
lines changed

.github/workflows/gradle.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build Plugin
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
paths: [ src/**, build.gradle.kts, settings.gradle.kts ]
8+
9+
permissions:
10+
contents: write
11+
actions: read
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: 21
28+
29+
- uses: gradle/actions/setup-gradle@v4
30+
31+
- run: |
32+
gradle wrapper
33+
chmod +x ./gradlew
34+
./gradlew shadowJar
35+
36+
- id: vars
37+
run: |
38+
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
39+
./gradlew -q printVars | sed 's/ = /=/g' >> "$GITHUB_OUTPUT"
40+
41+
- id: ghck
42+
run: |
43+
CODE=$(curl -s -o /dev/null -w "%{http_code}" \
44+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
45+
-H "X-GitHub-Api-Version: 2022-11-28" \
46+
"https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.vars.outputs.VERS }}")
47+
if [ "$CODE" = "200" ]; then
48+
echo "EXISTS=true" >> "$GITHUB_OUTPUT"
49+
else
50+
echo "EXISTS=false" >> "$GITHUB_OUTPUT"
51+
fi
52+
53+
- id: mrck
54+
run: |
55+
echo "TOKEN=$([ -n "${{ secrets.MODRINTH_TOKEN }}" ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
56+
57+
- id: dist
58+
run: |
59+
echo "TAG_NAME=${{ format('v{0}{1}', steps.vars.outputs.VERS, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT"
60+
echo "REL_NAME=${{ format('{0}{1}', steps.ghck.outputs.EXISTS == 'true' && 'Snapshot ' || 'v', steps.ghck.outputs.EXISTS == 'true' && steps.vars.outputs.COMMIT_HASH || steps.vars.outputs.VERS) }}" >> "$GITHUB_OUTPUT"
61+
echo "ART_NAME=${{ format('{0}{1}.jar', steps.vars.outputs.AFCT, steps.ghck.outputs.EXISTS == 'true' && format('+{0}', steps.vars.outputs.COMMIT_HASH) || '') }}" >> "$GITHUB_OUTPUT"
62+
63+
- run: |
64+
mkdir -p dist
65+
cp "./build/libs/${{ steps.vars.outputs.AFCT }}.jar" ./dist/${{ steps.dist.outputs.ART_NAME }}
66+
67+
- uses: actions/upload-artifact@v4
68+
with:
69+
path: dist/${{ steps.dist.outputs.ART_NAME }}
70+
name: ${{ steps.dist.outputs.ART_NAME }}
71+
72+
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
tag_name: ${{ steps.dist.outputs.TAG_NAME }}
76+
name: ${{ steps.dist.outputs.REL_NAME }}
77+
files: dist/${{ steps.dist.outputs.ART_NAME }}
78+
prerelease: ${{ steps.ghck.outputs.EXISTS == 'true' }}
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.gradle/
2+
/.vscode/
3+
/gradle/**
4+
/build/
5+
/bin/
6+
/run/
7+
/gradlew
8+
/gradlew.bat
9+
!/gradle/wrapper/
10+
!/gradle/wrapper/*.properties

LICENSE.md

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

build.gradle.kts

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
import groovy.lang.Closure
2+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
3+
import com.palantir.gradle.gitversion.VersionDetails
4+
import org.gradle.api.tasks.compile.JavaCompile
5+
import org.gradle.language.jvm.tasks.ProcessResources
6+
import xyz.jpenilla.runpaper.task.RunServer
7+
import xyz.jpenilla.runwaterfall.task.RunWaterfall
8+
import xyz.jpenilla.runvelocity.task.RunVelocity
9+
10+
11+
12+
13+
val PLUGIN_NAME = "MaintenanceMOTDEagler"
14+
val PLUGIN_IDEN = "maintenancemotdeagler"
15+
val PLUGIN_DOMN = "xyz.webmc.$PLUGIN_IDEN"
16+
val PLUGIN_DESC = "An EaglerXServer addon to display the maintenance MOTD."
17+
val PLUGIN_VERS = "1.0.0"
18+
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
19+
val PLUGIN_DEPA = listOf("EaglercraftXServer", "Maintenance")
20+
val PLUGIN_DEPB = listOf("EaglercraftXServer", "Maintenance")
21+
val PLUGIN_DEPC = listOf("eaglerxserver", "maintenance")
22+
val PLUGIN_SDPA = emptyList<String>()
23+
val PLUGIN_SDPB = emptyList<String>()
24+
val PLUGIN_SDPC = emptyList<String>()
25+
val PLUGIN_PROV = emptyList<String>()
26+
val PLUGIN_ATHR = listOf("Colbster937")
27+
val PLUGIN_CTBR = emptyList<String>()
28+
29+
30+
31+
32+
val PLUGIN_DEPA_J = getBukkitBungeeDeps(PLUGIN_DEPA)
33+
val PLUGIN_DEPB_J = getBukkitBungeeDeps(PLUGIN_DEPB)
34+
val PLUGIN_DEPC_J = getVelocityDeps(PLUGIN_DEPC, PLUGIN_SDPC)
35+
val PLUGIN_SDPA_J = getBukkitBungeeDeps(PLUGIN_SDPA)
36+
val PLUGIN_SDPB_J = getBukkitBungeeDeps(PLUGIN_SDPB)
37+
val PLUGIN_PROV_J = getBukkitBungeeDeps(PLUGIN_PROV)
38+
val PLUGIN_ATHR_J = getBukkitBungeeDeps(PLUGIN_ATHR)
39+
val PLUGIN_CTBR_J = getBukkitBungeeDeps(PLUGIN_CTBR)
40+
41+
val EAGXS_VER = "1.0.8"
42+
val MTNCE_VER = "4.2.1"
43+
44+
plugins {
45+
id("java")
46+
id("com.gradleup.shadow") version "9.3.1"
47+
id("com.palantir.git-version") version "4.2.0"
48+
id("xyz.jpenilla.run-paper") version "3.0.2"
49+
id("xyz.jpenilla.run-waterfall") version "3.0.2"
50+
id("xyz.jpenilla.run-velocity") version "3.0.2"
51+
}
52+
53+
@Suppress("UNCHECKED_CAST")
54+
val GIT_INFO = (extra["versionDetails"] as Closure<VersionDetails>)()
55+
56+
repositories {
57+
mavenCentral()
58+
maven("https://repo.papermc.io/repository/maven-public/")
59+
maven("https://oss.sonatype.org/content/groups/public/")
60+
maven("https://hub.spigotmc.org/nexus/content/repositories/public/")
61+
maven("https://repo.md-5.net/content/repositories/releases/")
62+
maven("https://repo.aikar.co/nexus/content/groups/aikar/")
63+
maven("https://repo.lax1dude.net/repository/releases/")
64+
}
65+
66+
dependencies {
67+
compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
68+
compileOnly("org.bukkit:bukkit:1.8-R0.1-SNAPSHOT")
69+
compileOnly("net.md-5:bungeecord-api:1.21-R0.5-SNAPSHOT")
70+
compileOnly("net.lax1dude.eaglercraft.backend:api-velocity:1.0.0")
71+
compileOnly("net.lax1dude.eaglercraft.backend:api-bungee:1.0.0")
72+
compileOnly("net.lax1dude.eaglercraft.backend:api-bukkit:1.0.0")
73+
compileOnly("eu.kennytv.maintenance:maintenance-api:" + MTNCE_VER)
74+
compileOnly("eu.kennytv.maintenance:maintenance-spigot:" + MTNCE_VER)
75+
compileOnly("eu.kennytv.maintenance:maintenance-bungee:" + MTNCE_VER)
76+
compileOnly("eu.kennytv.maintenance:maintenance-velocity:" + MTNCE_VER)
77+
implementation("net.kyori:adventure-text-minimessage:4.26.1")
78+
implementation("net.kyori:adventure-text-serializer-legacy:4.26.1")
79+
}
80+
81+
sourceSets {
82+
named("main") {
83+
java.srcDir("./src/main/java")
84+
resources.srcDir("./src/main/resources")
85+
}
86+
}
87+
88+
java {
89+
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
90+
}
91+
92+
val BUILD_PROPS = mapOf(
93+
"plugin_name" to PLUGIN_NAME,
94+
"plugin_iden" to PLUGIN_IDEN,
95+
"plugin_desc" to PLUGIN_DESC,
96+
"plugin_vers" to PLUGIN_VERS,
97+
"plugin_site" to PLUGIN_SITE,
98+
"plugin_depa" to PLUGIN_DEPA_J,
99+
"plugin_depb" to PLUGIN_DEPB_J,
100+
"plugin_depc" to PLUGIN_DEPC_J,
101+
"plugin_sdpa" to PLUGIN_SDPA_J,
102+
"plugin_sdpb" to PLUGIN_SDPB_J,
103+
"plugin_prov" to PLUGIN_PROV_J,
104+
"plugin_athr" to PLUGIN_ATHR_J,
105+
"plugin_ctbr" to PLUGIN_CTBR_J,
106+
"git_cm_hash" to GIT_INFO.gitHashFull,
107+
)
108+
109+
tasks.withType<JavaCompile>().configureEach {
110+
options.encoding = "UTF-8"
111+
options.release.set(17)
112+
}
113+
114+
tasks.withType<ProcessResources>().configureEach {
115+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
116+
outputs.upToDateWhen { false }
117+
118+
doFirst {
119+
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) {
120+
expand(BUILD_PROPS)
121+
}
122+
}
123+
124+
doLast {
125+
val file = destinationDir.resolve("build.properties")
126+
file.parentFile.mkdirs()
127+
file.writeText(
128+
BUILD_PROPS.entries.joinToString("\n") { (k, v) ->
129+
"$k = $v"
130+
}
131+
)
132+
}
133+
134+
inputs.files(tasks.named<JavaCompile>("compileJava").map { it.outputs.files })
135+
}
136+
137+
tasks.withType<Jar>().configureEach {
138+
enabled = false
139+
}
140+
141+
tasks.withType<ShadowJar>().configureEach {
142+
enabled = true
143+
doFirst {
144+
delete(layout.buildDirectory.dir("libs"))
145+
mkdir(layout.buildDirectory.dir("libs"))
146+
}
147+
archiveFileName.set("$PLUGIN_NAME-$PLUGIN_VERS.jar")
148+
}
149+
150+
tasks.named("build") {
151+
dependsOn(tasks.named("shadowJar"))
152+
}
153+
154+
tasks.register("printVars") {
155+
group = "help"
156+
doLast {
157+
println("VERS = " + PLUGIN_VERS)
158+
println("AFCT = " + tasks.named("shadowJar").get().outputs.files.singleFile.name.removeSuffix(".jar"))
159+
}
160+
}
161+
162+
tasks.withType<RunServer>().configureEach {
163+
minecraftVersion("1.12.2")
164+
runDirectory.set(layout.projectDirectory.dir("run/paper"))
165+
jvmArgs("-Dcom.mojang.eula.agree=true")
166+
downloadPlugins {
167+
github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar")
168+
github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-" + MTNCE_VER + ".jar")
169+
}
170+
}
171+
172+
tasks.withType<RunWaterfall>().configureEach {
173+
waterfallVersion("1.21")
174+
runDirectory.set(layout.projectDirectory.dir("run/waterfall"))
175+
downloadPlugins {
176+
github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar")
177+
github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-" + MTNCE_VER + ".jar")
178+
}
179+
}
180+
181+
tasks.withType<RunVelocity>().configureEach {
182+
velocityVersion("3.4.0-SNAPSHOT")
183+
runDirectory.set(layout.projectDirectory.dir("run/velocity"))
184+
downloadPlugins {
185+
github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar")
186+
github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-Velocity-" + MTNCE_VER + ".jar")
187+
}
188+
}
189+
190+
fun getBukkitBungeeDeps(list: List<String>): String {
191+
return list.joinToString(
192+
prefix = "[",
193+
postfix = "]"
194+
) { "\"$it\"" }
195+
}
196+
197+
fun getVelocityDeps(a: List<String>, b: List<String>): String {
198+
val c = a.joinToString(", ") { "{\"id\":\"$it\",\"optional\":false}" }
199+
val d = b.joinToString(", ") { "{\"id\":\"$it\",\"optional\":true}" }
200+
return "[" + listOf(c, d).filter { it.isNotEmpty() }.joinToString(",") + "]"
201+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.jvmargs = -Xmx1G
2+
org.gradle.parallel = true
3+
org.gradle.problems.report = false
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package xyz.webmc.maintenancemotdeagler.base;
2+
3+
import java.io.InputStream;
4+
import java.util.Properties;
5+
6+
public final class BuildInfo {
7+
private static final Properties properties;
8+
9+
public static final String get(final String key) {
10+
return properties.getProperty(key).trim();
11+
}
12+
13+
static {
14+
properties = new Properties();
15+
try (final InputStream in = BuildInfo.class.getClassLoader().getResourceAsStream("build.properties")) {
16+
properties.load(in);
17+
} catch (final Throwable t) {
18+
}
19+
}
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package xyz.webmc.maintenancemotdeagler.base;
2+
3+
import eu.kennytv.maintenance.core.MaintenancePlugin;
4+
5+
public interface IMaintenanceMOTDEaglerPlugin {
6+
public byte[] getFavicon(final MaintenancePlugin plugin);
7+
}

0 commit comments

Comments
 (0)