Skip to content

Commit a6fa559

Browse files
authored
Initial commit
0 parents  commit a6fa559

21 files changed

+847
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{kt,kts}]
10+
ktlint_code_style = intellij_idea
11+
12+
[*{.yml,yaml}]
13+
indent_style = space
14+
indent_size = 2
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
on:
3+
workflow_call:
4+
outputs:
5+
version:
6+
description: Built version
7+
value: ${{ jobs.build.outputs.version }}
8+
9+
jobs:
10+
build:
11+
name: Gradle Build
12+
runs-on: ubuntu-24.04
13+
outputs:
14+
version: ${{ steps.version.outputs.version }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: 21
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
- name: Gradle Build
27+
run: ./gradlew build shadowJar
28+
- name: Get Version
29+
id: version
30+
run: echo "version=$(./gradlew --console plain --quiet currentVersion -Prelease.quiet)" >> $GITHUB_OUTPUT
31+
- name: Upload build
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: build
35+
path: build/libs/*.jar
36+
retention-days: 7
37+
if-no-files-found: error
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Create Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionIncrementer:
7+
type: choice
8+
description: Override the default version incrementer according to https://axion-release-plugin.readthedocs.io/en/latest/configuration/version/#incrementing
9+
default: default
10+
options:
11+
- default
12+
- incrementPatch
13+
- incrementMinor
14+
- incrementMajor
15+
- incrementPrerelease
16+
17+
jobs:
18+
release:
19+
name: Gradle Release
20+
runs-on: ubuntu-24.04
21+
outputs:
22+
version: ${{ steps.version.outputs.version }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
ssh-key: "${{ secrets.COMMIT_KEY }}"
27+
fetch-depth: 0
28+
- uses: webfactory/[email protected]
29+
with:
30+
ssh-private-key: ${{ secrets.COMMIT_KEY }}
31+
- name: Setup Java
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'temurin'
35+
java-version: 21
36+
- uses: gradle/actions/setup-gradle@v4
37+
- name: Gradle Release
38+
if: ${{ inputs.versionIncrementer == 'default' }}
39+
run: ./gradlew release
40+
- name: Gradle Release w/ Increment Override
41+
if: ${{ inputs.versionIncrementer != 'default' }}
42+
run: ./gradlew release -Prelease.versionIncrementer=${{ inputs.versionIncrementer }}

.github/workflows/pr-workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: PR
2+
on: pull_request
3+
4+
jobs:
5+
build:
6+
uses: ./.github/workflows/build-workflow.yml
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches: ['master', 'main']
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build-workflow.yml
11+
release:
12+
needs: build
13+
name: Create Release
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Download build
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: build
21+
path: build
22+
- name: Release
23+
uses: docker://antonyurchenko/git-release:v6
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
RELEASE_NAME: ${{ needs.build.outputs.version }}
27+
PRE_RELEASE: ${{ github.ref_type == 'branch' }}
28+
UNRELEASED: ${{ github.ref_type == 'branch' && 'update' || '' }}
29+
UNRELEASED_TAG: latest-snapshot
30+
ALLOW_EMPTY_CHANGELOG: ${{ github.ref_type == 'branch' && 'true' || 'false' }}
31+
with:
32+
args: build/*.jar

.gitignore

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
2+
# Created by https://www.gitignore.io/api/gradle,intellij+all
3+
# Edit at https://www.gitignore.io/?templates=gradle,intellij+all
4+
5+
### Intellij+all ###
6+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
7+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
8+
9+
# User-specific stuff
10+
.idea/**/workspace.xml
11+
.idea/**/tasks.xml
12+
.idea/**/usage.statistics.xml
13+
.idea/**/dictionaries
14+
.idea/**/shelf
15+
16+
# Generated files
17+
.idea/**/contentModel.xml
18+
19+
# Sensitive or high-churn files
20+
.idea/**/dataSources/
21+
.idea/**/dataSources.ids
22+
.idea/**/dataSources.local.xml
23+
.idea/**/sqlDataSources.xml
24+
.idea/**/dynamic.xml
25+
.idea/**/uiDesigner.xml
26+
.idea/**/dbnavigator.xml
27+
28+
# Gradle
29+
.idea/**/gradle.xml
30+
.idea/**/libraries
31+
32+
# Gradle and Maven with auto-import
33+
# When using Gradle or Maven with auto-import, you should exclude module files,
34+
# since they will be recreated, and may cause churn. Uncomment if using
35+
# auto-import.
36+
# .idea/modules.xml
37+
# .idea/*.iml
38+
# .idea/modules
39+
40+
# CMake
41+
cmake-build-*/
42+
43+
# Mongo Explorer plugin
44+
.idea/**/mongoSettings.xml
45+
46+
# File-based project format
47+
*.iws
48+
49+
# IntelliJ
50+
out/
51+
52+
# mpeltonen/sbt-idea plugin
53+
.idea_modules/
54+
55+
# JIRA plugin
56+
atlassian-ide-plugin.xml
57+
58+
# Cursive Clojure plugin
59+
.idea/replstate.xml
60+
61+
# Crashlytics plugin (for Android Studio and IntelliJ)
62+
com_crashlytics_export_strings.xml
63+
crashlytics.properties
64+
crashlytics-build.properties
65+
fabric.properties
66+
67+
# Editor-based Rest Client
68+
.idea/httpRequests
69+
70+
# Android studio 3.1+ serialized cache file
71+
.idea/caches/build_file_checksums.ser
72+
73+
### Intellij+all Patch ###
74+
# Ignores the whole .idea folder and all .iml files
75+
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
76+
77+
.idea/
78+
79+
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
80+
81+
*.iml
82+
modules.xml
83+
.idea/misc.xml
84+
*.ipr
85+
86+
### Gradle ###
87+
.gradle
88+
/build/
89+
90+
# Ignore Gradle GUI config
91+
gradle-app.setting
92+
93+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
94+
!gradle-wrapper.jar
95+
96+
# Cache of project
97+
.gradletasknamecache
98+
99+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
100+
# gradle/wrapper/gradle-wrapper.properties
101+
102+
### Gradle Patch ###
103+
**/build/
104+
105+
# End of https://www.gitignore.io/api/gradle,intellij+all

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
### Added
5+
- Initial Release
6+
7+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9+
10+
[Unreleased]: https://github.com/SimpleMC/mc-kotlin-plugin-template/compare/5cb23facc562f7ddb9662a59a3162979599a348f...HEAD

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 SimpleMC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# mc-kotlin-plugin-template
2+
Opinionated template/starter for creating Minecraft plugins in Kotlin using the Spigot API
3+
4+
## Features
5+
6+
- Gradle axion-release-plugin for managing semver
7+
- automatic updating of `CHANGELOG.md` and `main/resources/plugin.yml` when a release is made
8+
- Github Actions to build PRs and automatically create Github releases when a release tag is pushed
9+
- Manual Create Version pipeline to increment semver tag and trigger publishing a new version
10+
- Requires a configured deploy key with write permission to the repository (see usage below)
11+
- [`ktlint`](https://github.com/JLLeitschuh/ktlint-gradle) Gradle plugin
12+
- Gradle build generates a standard plugin jar which will download dependencies declared as
13+
[`libraries`](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginDescriptionFile.html#getLibraries()) in
14+
`plugin.yml` and an "offline"/shadowed jar containing necessary dependencies
15+
16+
## Usage
17+
18+
1. Use the template to create a new repository: [Create a new repository](https://github.com/SimpleMC/mc-kotlin-plugin-template/generate)
19+
2. Change template repository references
20+
- `settings.gradle.kts` -> set `rootProject.name`
21+
- `gradle.properties` -> set `repoRef`
22+
- `build.gradle.kts` -> set `group`
23+
- `CHANGELOG.md` -> update links to `SimpleMC/mc-kotlin-plugin-template` to match `repoRef`
24+
- `src/main/resources/plugin.yml` -> set `name`, `main`, `website`, `author`
25+
- `src/main/kotlin/org/simplemc/plugintemplate/KotlinPluginTemplate.kt` -> Move packages/rename for your plugin
26+
- `README.md` -> Update
27+
3. To use the Create Version automation, add an SSH key
28+
1. Create an SSH key-pair (no password): `ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/<name_your_key>deploy`
29+
2. Add the Public Key as a Deploy Key (**Important! Enable `Allow write access`**): https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#set-up-deploy-keys an Actions secret to your new repository: `https://github.com/<repo slug>/settings/secrets/actions/new`
30+
3. Add the Private Key as an Actions secret: `https://github.com/<repo slug>/settings/secrets/actions/new`
31+
- Name: `COMMIT_KEY`
32+
- Secret Contents: Paste the Private key
33+
4. The GitHub Actions are configured to use this key to publish tags and release commits (see `.github/workflows/create-version.yml`)
34+
- See [axion-release-plugin Authorization](https://axion-release-plugin.readthedocs.io/en/latest/configuration/authorization/) for alternative Auth options
35+
36+
## Examples
37+
38+
Several SimpleMC plugins are built off of this template or were the impetus for it:
39+
40+
- [SimpleNPCs](https://github.com/SimpleMC/SimpleNPCs) - Simple command-based NPC interactions
41+
- [SimpleHealthbars2](https://github.com/SimpleMC/SimpleHealthbars2) - Simple, easy-to-use healthbar plugin with optional player and mob healthbars
42+
- [SimpleAnnounce](https://github.com/SimpleMC/SimpleAnnounce) - SimpleAnnounce is a simple and easy to use, yet powerful automated announcement plugin for the Bukkit Minecraft API.

0 commit comments

Comments
 (0)