Skip to content

Commit 098bd2f

Browse files
dmccoystephensonrenbindenChocolate1DonutTems-pyMestreWilll
authored
Release/v5.4 (#1822)
Co-authored-by: Ren Binden <ren.binden@gmail.com> Co-authored-by: Donut <86391164+Chocolate1Donut@users.noreply.github.com> Co-authored-by: Tems <79542785+Tems-py@users.noreply.github.com> Co-authored-by: Will <87247824+MestreWilll@users.noreply.github.com> Co-authored-by: MestreWilll <WillXOkumura@hotmail.com>
1 parent 83e2aaf commit 098bd2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1680
-80
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @alyphen @dmccoystephenson
1+
* @dmccoystephenson

.testcontainer/post-create.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
echo "Running 'post-create.sh' script..."
2+
if [ -z "$(ls -A /testmcserver)" ]; then
3+
echo "Setting up server..."
4+
# Copy server JAR
5+
cp /testmcserver-build/spigot-1.20.4.jar /testmcserver/spigot-1.20.4.jar
6+
7+
# Create plugins directory
8+
mkdir /testmcserver/plugins
9+
10+
# Create ops.json file on the fly
11+
echo "Creating ops.json file..."
12+
echo '[
13+
{
14+
"uuid": "0a9fa342-3139-49d7-8acb-fcf4d9c1f0ef",
15+
"name": "DanTheTechMan",
16+
"level": 4,
17+
"bypassesPlayerLimit": false
18+
}
19+
]' >> /testmcserver/ops.json
20+
21+
# Accept EULA
22+
cd /testmcserver && echo "eula=true" > eula.txt
23+
else
24+
echo "Server is already set up."
25+
fi
26+
27+
# Always delete lang directory to get the latest translations
28+
echo "Deleting lang directory..."
29+
rm -rf /testmcserver/plugins/MedievalFactions/lang
30+
31+
# Always copy the latest plugin JAR
32+
nameOfJar=$(ls /testmcserver-build/MedievalFactions/build/libs/*-all.jar)
33+
currentDate=$(date +%s)
34+
jarDate=$(date -r "$nameOfJar" +%s)
35+
diff=$((currentDate - jarDate))
36+
37+
if [ $diff -gt 300 ]; then
38+
echo "WARNING: The plugin JAR is older than 5 minutes. It may be necessary to rebuild the plugin."
39+
fi
40+
41+
echo "Copying plugin JAR... (created $diff seconds ago)"
42+
cp "$nameOfJar" /testmcserver/plugins
43+
44+
echo "Starting server..."
45+
java -jar /testmcserver/spigot-1.20.4.jar

CONTRIBUTING.md

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,67 @@
1-
# Contributing To The Project
1+
# Contributing Document
22
## Thank You
3-
Thank you so much for being willing to contribute to this project! It wouldn't be where it is today without the help of others. Please feel free to fork the repository and contact me on my [support discord server](https://discord.gg/xXtuAQ2).
3+
Thank you for being interested in contributing to the project! It wouldn't be where it is today without the help of the community. This document will help you get started with contributing to the project.
44

5-
## Some Things To Know
6-
- I use ZenHub to manage repository issues. This is optional for contributors.
7-
- Our highest priority issues will given the "priority" label. [Check them out here](https://github.com/dmccoystephenson/Medieval-Factions/issues?q=is%3Aissue+is%3Aopen+label%3Apriority)
5+
## Links
6+
- [Website](https://dansplugins.com)
7+
- [Discord](https://discord.gg/xXtuAQ2)
88

9-
## Process
10-
- When you fork the repository, make sure you are working on the "develop" branch.
11-
- When you start working on something, assign it to yourself. If there is no issue, you can optionally create one.
12-
- When you add new lines to the language files, make sure to add them to all 4 supported translations: en_US, en_GB, de_DE and fr_FR
13-
- When you add translations, make sure they are all on the same line.
14-
- When you're finished with something, open a pull request and assign it to yourself. If there is an associated issue, please link it in the PR using #(number).
9+
## Requirements
10+
- A GitHub account
11+
- Git installed on your local machine
12+
- A text editor or IDE
13+
- A basic understanding of Java
1514

16-
## Notes
17-
- If you start working on something, please remember to assign yourself to the related issues so I know what is being worked on.
18-
- If you edit a class, feel free to add an author annotation with your name. This is optional.
15+
## Getting Started
16+
- If you don't already have a GitHub account, you can sign up for one [here](https://github.com/signup).
17+
- Fork the repository on GitHub by clicking the "Fork" button on the top right of the repository page.
18+
- Clone your fork of the repository to your local machine using `git clone https://www.github.com/<your-username>/Medieval-Factions.git`
19+
- Open the project in your preferred text editor or IDE.
20+
- Try compiling the plugin using the following command:
21+
```bash
22+
gradlew build
23+
```
24+
If you encounter any errors, please create an issue for it.
1925

20-
## Bugs
21-
- When you encounter a bug that is in the code of the master branch, create an issue for it and assign it the 'Bug' label.
26+
## Identifying What To Work On
27+
### Issues
28+
Work items are tracked as GitHub issues. You can find a full list of issues [here](https://github.com/Dans-Plugins/Medieval-Factions/issues).
29+
30+
### Milestones
31+
Work items are organized into milestones, which represent a specific version of the plugin. You can find the milestones [here](https://github.com/Dans-Plugins/Medieval-Factions/milestones).
32+
33+
## Making Changes
34+
- Before you start working on something, make sure there is an issue for it. If there isn't, create one.
35+
- Make sure you are working on the "develop" branch. If you are not, switch to it using `git checkout develop`.
36+
- Create a new branch for your changes using `git checkout -b <branch-name>`. Make sure to name your branch something that is related to the issue you are working on.
37+
- Make your changes to the code.
38+
- Test your changes to make sure they work as expected. [More information on testing can be found here](#testing).
39+
- When you are finished, commit your changes using `git commit -m "Your commit message here"`.
40+
- Push your changes to your fork using `git push origin <branch-name>`.
41+
- Open a pull request on the original repository. Make sure to include a description of your changes and link the related issue using #(number). The develop branch should be used as the base branch.
42+
- Wait for your pull request to be reviewed. If there are any changes that need to be made, make them and push the changes to your fork. Your pull request will be updated automatically.
43+
- Once your pull request has been reviewed and approved, it will be merged into the develop branch.
44+
45+
### Language Files
46+
The plugin supports multiple languages. Code changes that require changes to the language files should include the changes to the language files as well. If you are adding a new language, you will need to create a new language file. The language files are located in the `src/main/resources/lang` directory.
47+
48+
## Testing
49+
At this time, there are no unit tests due to a difficulty mocking Spigot. However, you can test your changes by running the plugin on a Spigot server.
50+
51+
### Running a Spigot server with Docker
52+
If you don't have Docker installed, you can download it [here](https://www.docker.com/products/docker-desktop).
53+
54+
To run a Spigot server with Docker, you can use the following command:
55+
```bash
56+
docker compose up
57+
```
58+
59+
This will start a Spigot server on your local machine. You can connect to it using the IP `localhost` and the port `25565`.
60+
61+
If you make changes to the code, you can deploy the latest changes by rebuilding the Docker image:
62+
```bash
63+
docker compose up --build
64+
```
65+
66+
## Questions
67+
If you have any questions about contributing to the project, feel free to ask in the Discord server. You can join the Discord server [here](https://discord.gg/xXtuAQ2). This is the best place to ask questions.

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ RUN apt-get install -y git \
77
openjdk-17-jre \
88
wget
99

10-
# Create server directory
11-
WORKDIR /testmcserver
12-
1310
# Build server
11+
WORKDIR /testmcserver-build
1412
RUN wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
1513
RUN git config --global --unset core.autocrlf || :
1614
RUN java -jar BuildTools.jar --rev 1.20.4
17-
RUN echo "eula=true" > eula.txt
18-
RUN mkdir plugins
1915

20-
# Build plugin
21-
COPY . .
22-
RUN ./gradlew build
23-
RUN cp build/libs/*-all.jar plugins
16+
# Copy plugin jar
17+
COPY ./build/libs /testmcserver-build/MedievalFactions/build/libs
18+
19+
# Copy resources and make post-create.sh executable
20+
COPY ./.testcontainer /resources
21+
RUN chmod +x /resources/post-create.sh
2422

2523
# Run server
24+
WORKDIR /testmcserver
2625
EXPOSE 25565
27-
ENTRYPOINT java -jar spigot-1.20.4.jar
26+
ENTRYPOINT /resources/post-create.sh

Dockerfile.dynmap

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu
2+
3+
# Install dependencies
4+
RUN apt-get update
5+
RUN apt-get install -y git \
6+
openjdk-17-jdk \
7+
openjdk-17-jre \
8+
wget \
9+
git
10+
11+
# Create server directory
12+
WORKDIR /testmcserver
13+
14+
# Clone & build dynmap (placed here to take advantage of docker caching)
15+
RUN git clone https://github.com/webbukkit/dynmap
16+
WORKDIR /testmcserver/dynmap
17+
RUN /testmcserver/dynmap/gradlew :spigot:build
18+
WORKDIR /testmcserver
19+
20+
# Build server
21+
RUN wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
22+
RUN git config --global --unset core.autocrlf || :
23+
RUN java -jar BuildTools.jar --rev 1.20.4
24+
RUN echo "eula=true" > eula.txt
25+
RUN mkdir plugins
26+
27+
# Build plugin
28+
COPY . /testmcserver/MedievalFactions
29+
WORKDIR /testmcserver/MedievalFactions
30+
RUN /testmcserver/MedievalFactions/gradlew build
31+
WORKDIR /testmcserver
32+
33+
# Install plugin
34+
RUN cp /testmcserver/MedievalFactions/build/libs/*-all.jar /testmcserver/plugins
35+
36+
# Install dynmap
37+
RUN cp /testmcserver/dynmap/target/Dynmap-*.jar /testmcserver/plugins
38+
39+
# Run server
40+
EXPOSE 25565
41+
ENTRYPOINT java -jar spigot-1.20.4.jar

README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,14 @@ Medieval Factions is a system of mechanics that allows for the simulation of sov
55

66
A list of features can be found [here](https://github.com/dmccoystephenson/Medieval-Factions/wiki/Features).
77

8-
### Fifth Major Version - MF 5
9-
Medieval Factions 5 reimagines and reworks everything about the plugin. The development of the fifth major version of MF was led by [alyphen](https://github.com/alyphen) (creator of [RPKit](https://github.com/RP-Kit/RPKit/wiki)). Huge thanks to her!
10-
11-
#### What's changed
12-
This is a complete rewrite of Medieval Factions so everything has received a fresh coat of paint since 4.6.x/4.7.x. Commands, permissions, placeholders, etc should mostly be compatible, though some things have changed, such as locks, roles, and force commands.
8+
The development of the fifth major version of MF was led by [alyphen](https://github.com/alyphen) (creator of [RPKit](https://github.com/RP-Kit/RPKit/wiki)). Huge thanks to her!
139

1410
## Installation
1511
### First Time Installation
1612
1) You can download the plugin from [this page](https://www.spigotmc.org/resources/medieval-factions-sovereign-nation-simulator.79941/updates).
1713
2) Once downloaded, place the jar in the plugins folder of your server files.
1814
3) Restart your server.
1915

20-
### Upgrading from Medieval Factions 4
21-
22-
1. If you have a Medieval Factions 4 install, replace the Medieval Factions 4 jar with Medieval Factions 5.
23-
24-
2. On the next start, Medieval Factions 5 will detect the Medieval Factions 4 config and make a backup of all of the data in mf4_backup in the data folder. It will then proceed to generate the new config file, and shut down the server.
25-
26-
3. At this point, you should configure your database, if you have one.
27-
28-
If you have MySQL or MariaDB database, this should look something like:
29-
30-
```
31-
database:
32-
url: 'jdbc:mysql://127.0.0.1/database'
33-
dialect: 'MYSQL'
34-
username: 'username'
35-
password: 'password'
36-
```
37-
38-
If you do not have a MySQL database, you can ignore this, as the plugin will create an h2 file-based database in your server's working directory.
39-
40-
4. Start the server one more time, and the configuration and data from the Medieval Factions 4 backup will be migrated to your new Medieval Factions 5 install.
41-
4216
### Dynmap Integration
4317
Dynmap has been integrated with this plugin. In order to be able to view claimed land on a dynamic map, download and install the plugin [here](https://www.spigotmc.org/resources/dynmap.274/).
4418

@@ -66,6 +40,21 @@ Please fill out a bug report [here](https://github.com/dmccoystephenson/Medieval
6640
- [Contributing.md](https://github.com/dmccoystephenson/Medieval-Factions/blob/master/CONTRIBUTING.md)
6741
- [Notes for Developers](https://github.com/dmccoystephenson/Medieval-Factions/wiki/Developer-Notes)
6842

43+
## Testing
44+
### Unit Tests
45+
To run the unit tests, you can use the following command:
46+
47+
Linux:
48+
```bash
49+
./gradlew clean test
50+
```
51+
Windows:
52+
```cmd
53+
.\gradlew.bat clean test
54+
```
55+
56+
If you see BUILD SUCCESSFUL, then the tests have passed.
57+
6958
### Looking to create an add-on plugin?
7059
I recommend using [FactionsBridge](https://www.spigotmc.org/resources/factionsbridge.89716/) by [Retrix_Solutions](https://www.spigotmc.org/resources/authors/retrix_solutions.491191/). It would make your add-on plugin usable across a number of factions implementations.
7160

build.gradle

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "com.dansplugins"
10-
version = "5.3.0"
10+
version = "5.4.0"
1111

1212
def repoUsername = ""
1313
def repoPassword = ""
@@ -36,7 +36,7 @@ configurations {
3636
}
3737

3838
dependencies {
39-
implementation 'me.clip:placeholderapi:2.11.2'
39+
implementation 'me.clip:placeholderapi:2.11.6'
4040
implementation 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
4141
implementation 'us.dynmap:dynmap-api:2.2'
4242
implementation 'org.bstats:bstats-bukkit:3.0.0'
@@ -57,9 +57,14 @@ dependencies {
5757
implementation 'com.rpkit:rpk-lock-lib-bukkit:2.3.2:all'
5858
implementation 'com.dansplugins:ponder-bukkit:2.0.0'
5959
implementation 'com.dansplugins:ponder-commands:2.0.0'
60-
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
61-
testImplementation 'io.mockk:mockk:1.13.2'
6260
jooqGenerator 'org.jooq:jooq-meta-extensions:3.17.4'
61+
62+
// Use the Kotlin JUnit 5 integration.
63+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
64+
testImplementation("org.mockito:mockito-core:4.0.0")
65+
testImplementation("org.mockito:mockito-inline:4.0.0")
66+
67+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
6368
}
6469

6570
kotlin {
@@ -68,6 +73,13 @@ kotlin {
6873
}
6974
}
7075

76+
// Apply a specific Java toolchain to ease working on different environments.
77+
java {
78+
toolchain {
79+
languageVersion = JavaLanguageVersion.of(17)
80+
}
81+
}
82+
7183
tasks.named('check') {
7284
dependsOn 'installKotlinterPrePushHook'
7385
}
@@ -166,10 +178,6 @@ artifacts {
166178
archives shadowJar
167179
}
168180

169-
tasks.named('test') {
170-
useJUnitPlatform()
171-
}
172-
173181
publishing {
174182
repositories {
175183
maven {
@@ -192,3 +200,8 @@ publishing {
192200
}
193201
}
194202
}
203+
204+
tasks.named('test') {
205+
// Use JUnit Platform for unit tests.
206+
useJUnitPlatform()
207+
}

compose-dynmap.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
testmcserver:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile.dynmap
6+
image: mf-test-mc-server-with-dynmap
7+
container_name: mf-test-mc-server-with-dynmap
8+
ports:
9+
- "25565:25565"
10+
- "8123:8123"

compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ services:
55
container_name: mf-test-mc-server
66
ports:
77
- "25565:25565"
8+
volumes:
9+
- ./testmcserver:/testmcserver

down.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker compose down --remove-orphans

0 commit comments

Comments
 (0)