Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-MX authored Sep 11, 2024
0 parents commit 111be24
Show file tree
Hide file tree
Showing 21 changed files with 696 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
30 changes: 30 additions & 0 deletions .github/workflows/build-and-archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Will build your gradle project and archive the output jar files.
name: Build and Archive Gradle Project

# This action will run every time you push to the "main" branch.
on:
push:
branches:
- "main"

jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Checkout project sources
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Run build with Gradle Wrapper
run: ./gradlew build
- uses: actions/upload-artifact@v3
with:
name: build-outputs
path: build/libs/*.jar
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Will simply build your gradle project.
name: Build Gradle Project

# This action will run every time you push to the "dev" branch.
on:
push:
branches:
- "dev"

jobs:
build-project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Checkout project sources
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Run build with Gradle Wrapper
run: ./gradlew build
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import java.io.BufferedReader
import java.io.InputStreamReader

plugins {
alias(libs.plugins.runPaper)
alias(libs.plugins.paperweight) apply true
alias(libs.plugins.kotlinJvm) apply true
alias(libs.plugins.shadow) apply true

`maven-publish`
}

runPaper.folia.registerTask()

val id = findProperty("id").toString()
val pluginName = findProperty("plugin_name")

repositories {
mavenLocal()
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://maven.pvphub.me/releases")
maven("https://repo.dmulloy2.net/repository/public/")
maven("https://jitpack.io")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}

dependencies {
paperweight.paperDevBundle(libs.versions.paperApi.get())

compileOnly(libs.ktgui)
compileOnly(libs.placeholder.api)
}

tasks {
base {
archivesName = id
}

withType<ProcessResources> {
val props = mapOf(
"name" to pluginName,
"main" to "${findProperty("group_name")}.${id}.${findProperty("plugin_main_class_name")}",
"author" to findProperty("plugin_author"),
"version" to if (findProperty("include_commit_hash")
.toString().toBoolean()
) "${rootProject.version}-commit-${getCurrentCommitHash()}" else rootProject.version.toString()
)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}

shadowJar {
mergeServiceFiles()
}

test {
useJUnitPlatform()
}

assemble {
dependsOn("reobfJar")
}

runServer {
val mcVersion = libs.versions.paperApi.get().split("-")[0]
minecraftVersion(mcVersion)

downloadPlugins {
hangar("ViaVersion", "5.0.1")
hangar("ViaBackwards", "5.0.1")
hangar("PlaceholderAPI", "2.11.6")
}
}
}

java {
withJavadocJar()
withSourcesJar()
}

kotlin {
jvmToolchain(17)
}

sourceSets["main"].resources.srcDir("src/resources/")

publishing {
repositories {
maven {
name = "pvphub-releases"
url = uri("https://maven.pvphub.me/releases")
credentials {
username = System.getenv("PVPHUB_MAVEN_USERNAME")
password = System.getenv("PVPHUB_MAVEN_SECRET")
}
}
}
publications {
create<MavenPublication>(id) {
from(components["java"])
groupId = group.toString()
artifactId = id
version = rootProject.version.toString()
}
}
}

fun getCurrentCommitHash(): String {
val process = ProcessBuilder("git", "rev-parse", "HEAD").start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val commitHash = reader.readLine()
reader.close()
process.waitFor()
if (process.exitValue() == 0) {
return commitHash?.substring(0, 7) ?: ""
} else {
throw IllegalStateException("Failed to retrieve the commit hash.")
}
}
12 changes: 12 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kotlin.code.style=official

# Project configuration
group_name = com.mattmx
id = template
version = 1.0

plugin_name = Template
plugin_main_class_name = TemplatePlugin
plugin_author = MattMX

include_commit_hash = true
26 changes: 26 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[versions]

paperweight = "1.7.1"
kotlin = "2.0.0"
updateVersions = "0.51.0"
shadow = "8.1.8"
paperApi = "1.20.4-R0.1-SNAPSHOT"
placeholderapi = "2.11.6"
ktgui = "2.4.2-alpha"
runPaper = "2.2.4"

[libraries]

kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paperApi" }
placeholder-api = { module = "me.clip:placeholderapi", version.ref = "placeholderapi" }
ktgui = { module = "com.mattmx:ktgui", version.ref = "ktgui" }

[plugins]

kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
updateDeps = { id = "com.github.ben-manes.versions", version.ref = "updateVersions" }
shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" }
paperweight = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" }
runPaper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 111be24

Please sign in to comment.