Skip to content

Commit ff536cf

Browse files
committed
1,2, new version with overtime support
1 parent d0fbdbd commit ff536cf

11 files changed

+363
-291
lines changed

.github/workflows/release.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: Release
22

3-
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
workflow_dispatch:
3+
on: workflow_dispatch
84

95
jobs:
106
build:

.gitignore

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1-
/.idea/
2-
/.vscode/
3-
/.gradle/
4-
1+
## Gradle
2+
.gradle/
53
build/
4+
5+
## Java
6+
*.class
7+
hs_err_pid*
8+
crash-report-*
9+
10+
## Intellij
11+
.idea/
12+
*.ipr
13+
*.iws
14+
*.iml
15+
16+
## Eclipse
17+
bin/
18+
.metadata/
19+
.settings/
20+
.classpath
21+
.project
22+
.loadpath
23+
24+
## VSCode
25+
.vscode/
26+
27+
## OS Specific
28+
.DS_Store
29+
Thumbs.db

README.md

+6-24
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# DominationPlugin
1+
# TemplatePlugin
22

3-
[![Jitpack latest version](https://jitpack.io/v/fr.xpdustry/DominationPlugin.svg)](https://jitpack.io/#fr.xpdustry/DominationPlugin)
4-
[![Build status](https://github.com/Xpdustry/DominationPlugin/actions/workflows/build.yml/badge.svg?branch=master&event=push)](https://github.com/Xpdustry/DominationPlugin/actions/workflows/build.yml)
5-
[![Mindustry 5.0 | 6.0](https://img.shields.io/badge/Mindustry-5.0%20%7C%206.0-ffd37f)](https://github.com/Anuken/Mindustry/releases)
3+
[![Jitpack latest version](https://jitpack.io/v/fr.xpdustry/TemplatePlugin.svg)](https://jitpack.io/#fr.xpdustry/TemplatePlugin)
4+
[![Build status](https://github.com/Xpdustry/TemplatePlugin/actions/workflows/build.yml/badge.svg?branch=master&event=push)](https://github.com/Xpdustry/TemplatePlugin/actions/workflows/build.yml)
5+
[![Mindustry 5.0 | 6.0 | 7.0 ](https://img.shields.io/badge/Mindustry-5.0%20%7C%206.0%20%7C%207.0-ffd37f)](https://github.com/Anuken/Mindustry/releases)
66

77
## Description
88

@@ -20,27 +20,9 @@ This template features some cool stuff such as:
2020

2121
## Tips and nice things to know
2222

23-
- When you use this template, make sure you change the information in `plugin.json`
24-
and set the `serverDirectoryPath`, `group` and `mindustryVersion` properties in `build.gradle`.
25-
There is also the `rootProject.name` property in `settings.gradle`.
23+
- When you use this template, make sure to edit `plugin.json` and `gradle.properties`.
2624

27-
- The plugin compiles to java 8 for compatibility reasons,
25+
- The plugin compiles to java 8 for maximum compatibility,
2826
but nothing keeps you to change the compiler target or source to a higher jdk.
2927

30-
- For faster testing, I recommend you to add an exit statement at the end of your server startup script such as:
31-
32-
`run_server.bat`
33-
```batch
34-
@echo off
35-
java -jar server.jar
36-
exit
37-
```
38-
39-
`run_server.sh`
40-
```shell
41-
#!/usr/bin/env bash
42-
java -jar server.jar
43-
exit
44-
```
45-
4628
Thank you for using this template !

build.gradle

+45-64
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
import groovy.json.JsonSlurper
2-
import org.gradle.internal.os.OperatingSystem
2+
import java.nio.charset.StandardCharsets
33

44

55
buildscript{
66
ext{
7-
// Mindustry API version you want to use
8-
mindustryVersion = "v126.2"
9-
10-
// Junit version for tests outside a server
11-
junitVersion = "5.7.2"
12-
7+
// Properties
8+
mindustryVersion = property("props.mindustry-version")
9+
serverDirectoryPath = property("props.mindustry-server-directory")
1310
// Plugin metadata extracted from plugin.json
1411
metadata = new JsonSlurper().parseText(file("$rootDir/plugin.json").text)
15-
16-
// A string that points directly to your server.jar directory
17-
serverDirectoryPath = null
18-
19-
// the file:// at the beginning is required if you use windows if you don't want github actions to scream at you
20-
if(System.getProperty("user.name") == "Finley"){
21-
serverDirectoryPath = "file://C:/Users/Finley/Documents/My Games/Mindustry/Server/mindustry-server-$mindustryVersion"
22-
}
2312
}
2413

2514
repositories{
@@ -40,7 +29,7 @@ plugins{
4029
}
4130

4231

43-
group "fr.xpdustry"
32+
group property("props.project-group")
4433
version metadata.version
4534

4635

@@ -50,56 +39,58 @@ repositories{
5039
}
5140

5241
dependencies{
42+
// Json
43+
implementation "com.google.code.gson:gson:2.8.8"
44+
testImplementation "com.google.code.gson:gson:2.8.8"
45+
5346
// Mindustry
5447
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
5548
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
5649

5750
// Unit Testing
5851
testImplementation "com.github.Anuken.Arc:arc-core:$mindustryVersion"
5952
testImplementation "com.github.Anuken.Mindustry:core:$mindustryVersion"
60-
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
61-
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
62-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
53+
testImplementation "org.junit.jupiter:junit-jupiter-params:5.8.1"
54+
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1"
55+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1"
6356
}
6457

6558

59+
java{
60+
withSourcesJar()
61+
}
62+
6663
compileJava{
67-
sourceCompatibility = JavaVersion.VERSION_15
68-
targetCompatibility = JavaVersion.VERSION_15
69-
options.encoding = "UTF-8"
64+
sourceCompatibility = JavaVersion.VERSION_16
65+
targetCompatibility = JavaVersion.VERSION_16
66+
options.encoding = StandardCharsets.UTF_8
7067
}
7168

72-
java{
73-
withSourcesJar()
69+
test{
70+
useJUnitPlatform()
71+
}
72+
73+
compileTestJava{
74+
options.encoding = StandardCharsets.UTF_8
7475
}
7576

77+
7678
jar{
79+
archiveBaseName = project.property("props.project-name")
80+
7781
// The following line is required
7882
from configurations.runtimeClasspath.collect{
7983
it.isDirectory() ? it : zipTree(it)
8084
}
8185

82-
from "plugin.json"
83-
}
84-
85-
86-
compileTestJava{
87-
options.encoding = "UTF-8"
88-
}
89-
90-
test{
91-
useJUnitPlatform()
86+
from "$rootDir/plugin.json"
9287
}
9388

9489

9590
task moveJar{
9691
dependsOn jar
9792

9893
doLast{
99-
if(serverDirectoryPath == null || serverDirectoryPath.isEmpty()){
100-
throw new GradleException("serverDirectoryPath is unset")
101-
}
102-
10394
// Deletes all the jar files that begins with the base artifact name
10495
delete file("$serverDirectoryPath/config/mods").listFiles({
10596
it.isFile() && it.name.endsWith(".jar") && it.name.startsWith((String) jar.archiveBaseName.get())
@@ -112,41 +103,31 @@ task moveJar{
112103
}
113104
}
114105

115-
task runServer{
116-
doLast{
117-
if(serverDirectoryPath == null || serverDirectoryPath.isEmpty()){
118-
throw new GradleException("serverDirectoryPath is unset")
119-
}
120-
121-
exec{
122-
OperatingSystem os = OperatingSystem.current()
123-
124-
workingDir = file(serverDirectoryPath)
125-
126-
// Open a mindustry server in a new terminal window
127-
if(os.isWindows()){
128-
commandLine = ["cmd", "/C", "start", "run_server.bat"]
129-
}else if(os.isLinux()){
130-
commandLine = ["sh", "-c", "./run_server.sh"]
131-
}else{
132-
throw new GradleException("Unsuported operation, please implement a case for your os")
133-
}
134-
}
135-
}
106+
task runServer(type: JavaExec){
107+
workingDir = serverDirectoryPath
108+
classpath = files("$serverDirectoryPath/server.jar")
109+
mainClass = "mindustry.server.ServerLauncher"
110+
standardInput = System.in
111+
args = ["host Veins pvp"]
136112
}
137113

138114
task deployJar{
139115
dependsOn moveJar
140116
dependsOn runServer
141117
}
142118

143-
// Required if you want to use the Release GitHub action,
144-
task getArtifactPath{
145-
doLast{
146-
println jar.archiveFile.get().toString()
119+
// Makes sure the task are only available if the props.mindustry-server-directory is set correctly
120+
for(Task serverTask : [moveJar, runServer, deployJar]){
121+
serverTask.configure{
122+
onlyIf{ file(serverDirectoryPath).exists() }
147123
}
148124
}
149125

126+
// Required if you want to use the Release GitHub action
127+
task getArtifactPath{
128+
doLast{ println jar.archiveFile.get().toString() }
129+
}
130+
150131

151132
publishing{
152133
publications{
@@ -157,7 +138,7 @@ publishing{
157138
name = metadata.displayName
158139
artifactId = metadata.name
159140
description = metadata.description
160-
url = "https://github.com/$metadata.repo"
141+
url = "https://github.com/$metadata.repo"
161142

162143
licenses{
163144
license{

gradle.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The project name, used as the artifact name
2+
props.project-name = DominationPlugin
3+
# Group of the project, usually a domain backwards such as com.google
4+
props.project-group = fr.xpdustry
5+
# Version of Mindustry API to use
6+
props.mindustry-version = v126.2
7+
# The path to your server.jar directory
8+
# The file:// at the beginning is required if you use windows if you don't want github actions to scream at you
9+
props.mindustry-server-directory = file://D:/Games/Mindustry/Builds/mindustry-server-v126.2

plugin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "domination-plugin",
2+
"name": "xpdustry-domination-plugin",
33
"displayName": "Xpdustry DominationPlugin",
44
"author": "Phinner",
55
"description": "Capture the zones to win!",
6-
"version": "1.1",
6+
"version": "1.2",
77
"minGameVersion": "105",
88
"hidden": true,
99
"java": true,

settings.gradle

-1
This file was deleted.

src/main/java/fr/xpdustry/domination/DominationIO.java

-81
This file was deleted.

0 commit comments

Comments
 (0)