diff --git a/.github/workflows/CleanUpTemplate.yml b/.github/workflows/CleanUpTemplate.yml index ef729f4..3d30894 100644 --- a/.github/workflows/CleanUpTemplate.yml +++ b/.github/workflows/CleanUpTemplate.yml @@ -18,7 +18,12 @@ jobs: - name: Run Cleanup Script env: FULL_NAME: ${{ github.event.repository.full_name }} - run: python cleanup.py "$FULL_NAME" + run: | + if [ -f cleanup.py ]; then + python cleanup.py "$FULL_NAME" + else + rm .github/workflows/CleanUpTemplate.yml + fi # Commit modified files - name: Commit files diff --git a/README.md b/README.md index 2f81789..a7aec76 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Mindustry Mod Template -This template utilized [MGPP gradle plugin](https://plumygame.github.io/mgpp/) to build and debug a mod. +#### *[MGPP](https://plumygames.github.io/mgpp/) helps you to build and debug a Java mod.* @@ -10,31 +10,67 @@ ___ It's recommended to `watch` this project, which will notify you anything updated of the template. -## How to use this template +## How To Use This Template -Hit the [green button](https://github.com/liplum/mdtmodtemplate/generate) `Use this template` above, not the `fork`, and enter your repository name, always the same as a mod name. +Above all, please take a look at the documentation of [MGPP](https://plumygames.github.io/mgpp/). +It'll help you to build your mod, run the Mindustry and debug your mod in game! -After the GitHub actions has done the clean-up job, you can clone your repository. +### GitHub Automation -There will be a generated `main class` and `mod.hjson`. +- Step 1: Hit the green button [Use this template](https://github.com/liplum/MindustryModTemplate/generate) above. +- Step 2: Enter your repository name, which is used to generate `mod.hjson`. +- Step 3: After GitHub Action has done the cleanup job, clone your repository. + ```shell + git clone https://github.com//.git + ``` + +### Manually Clone + +- Step 1: Clone this template. + ```shell + git clone https://github.com/liplum/MindustryModTemplate.git + ``` +- Step 2: Delete `.git` folder. + ```shell + cd + rm -rf .git + ``` + +You need [Python 3](https://www.python.org/) installed on your computer to run the cleanup script. +Otherwise, you can just delete the [cleanup.py](cleanup.py) file in the root folder. + +Replace `` to your name, `` to your mod name bellow, and run the command. + +```shell +python cleanup.py "/" +``` + +It will clean up your project and generate essential files. ## Building through GitHub Actions -Check the "Actions" tab on your repository page. -Select the most recent commit in the list. +Check the "Actions" tab on your repository page. +Select the most recent commit in the list. If it completed successfully, there should be a download link under the "Artifacts" section, that could work on both Desktop and Android. -## Generating release draft -Any push whose head commit contains `[release]` in its message, a release draft will be generated on GitHub. +## Create a Release Draft + +- Step 1: Check the "Actions" tab on your repository page. +- Step 2: Find `Creat Release Draft` on the left hand. +- Step 3: Hit `Run workflow` button and run on a branch you want, mostly, it's `master`. + +Then a release draft with a `.jar` file, it's your mod, will be generated on GitHub. ## Gradle DSL and Kotlin -You can select which `Gradle DSL` to use, by easily deleting `build.gradle` or `build.gradle.kts`. +You can select which `Gradle DSL` to use by easily deleting either `build.gradle` or `build.gradle.kts`. + If you kept both, it would use `build.gradle` as default. -If you want to make a Kotlin mod, please keep the `build.gradle.kts` and remove `build.gradle`. +If you want to make a Kotlin mod, please delete `build.gradle`. ## Licence + GNU General Public License v3.0 diff --git a/cleanup.py b/cleanup.py index 9e32fbc..d5a67db 100644 --- a/cleanup.py +++ b/cleanup.py @@ -3,10 +3,14 @@ import io args = sys.argv -full_name = args[1] +if len(args) == 1: + full_name = "example/ExampleMod" +else: + full_name = args[1] owner, repo = full_name.split('/') package_name = owner.replace("-", "") main_class_template = """package %PackageName%; + import mindustry.mod.*; public class %MainClassName% extends Mod { @@ -33,11 +37,10 @@ """ -def transform_repo_to_class_name() -> str: +def transform_repo_to_class_name(): with io.StringIO() as b: hyphen = False for i, c in enumerate(repo): - c: str if c == '-': hyphen = True else: @@ -50,7 +53,8 @@ def transform_repo_to_class_name() -> str: else: b.write(c) name: str = b.getvalue() - name = name.removesuffix("Mod") + if name.endswith("Mod"): + return name[:-len("Mod")] return name