Skip to content

Commit

Permalink
detailed use guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Jan 31, 2023
1 parent 93c755b commit 963fc79
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 16 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/CleanUpTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 47 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,75 @@

# 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.*

</div>

___

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/<your-name>/<your-repo>.git
```

### Manually Clone

- Step 1: Clone this template.
```shell
git clone https://github.com/liplum/MindustryModTemplate.git <your-mod-name>
```
- Step 2: Delete `.git` folder.
```shell
cd <your-mod-name>
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 `<author>` to your name, `<your-mod-name>` to your mod name bellow, and run the command.

```shell
python cleanup.py "<author>/<your-mod-name>"
```

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
12 changes: 8 additions & 4 deletions cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand All @@ -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


Expand Down

0 comments on commit 963fc79

Please sign in to comment.