Skip to content
Merged

v4 #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
docker/
.git/
.idea/
*.iml
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
push:
branches-ignore:
- main
pull_request:

permissions:
contents: read

concurrency:
group: tests-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Java ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# The Java versions required by the supported Minecraft versions (1.18–1.20.4, 1.20.5–1.21.x, 26.x).
java: [17, 21, 25]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
cache: maven

- name: Build and test
run: mvn -B verify

- name: Upload test reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: surefire-reports-java-${{ matrix.java }}
path: target/surefire-reports/
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
.idea/
*.iws
*.iml
*.ipr
Expand Down Expand Up @@ -35,4 +32,6 @@ build/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store
### Docker development ###
docker/plugins/*.jar
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build and test image: JDK + Maven, nothing else needed on the host.
# docker compose run --rm build
FROM maven:3.9-eclipse-temurin-21

WORKDIR /workspace

# Resolve dependencies in their own layer so source changes don't re-download them.
COPY pom.xml .
RUN mvn -B -q dependency:go-offline || true

COPY src ./src

CMD ["mvn", "-B", "verify"]
75 changes: 22 additions & 53 deletions README-PL.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,30 @@
Angielska wersja znajduje się [tutaj](README.md).

# VoteReward

VoteReward to plugin pod Spigot pozwalający na przyznawanie nagród graczom za głosowanie na serwer. Został stworzony pod
wersje powyżej 1.18. Statystyki projektu dostępne na
stronie [bStats](https://bstats.org/plugin/bukkit/VoteReward/20120).

# Instalacja

Pobierz najnowszą wersję pluginu [tutaj](https://github.com/dudekm/VoteReward/releases/latest).

Po pobraniu pliku `.jar`, należy umieścić go w folderze "plugins" w głównym katalogu serwera, a następnie zrestartować
serwer. Po ponownym uruchomieniu powinien zostać utworzony folder "VoteReward" zawierający plik konfiguracyjny.

Teraz w `settings.yml` należy skonfigurować serwery, na które mogą głosować gracze. W tym celu przechodzimy do
sekcji `servers`. Jej domyślna forma wygląda następująco:

```yaml
servers:
lista-minecraft:
address: https://lista-minecraft.pl
uuid: 183413bc-4588-4265-8f06-346963e5d7df
reward-commands:
- xp add %player_name% 100
- give %player_name% diamond
lista-serwerow-emecz:
address: https://lista-serwerow.emecz.pl
uuid: 264acafc-136c-4def-a363-088587c7a405
reward-commands: []
minecraft-list:
address: https://minecraft-list.info
uuid: d6dfe480-da3a-495a-a92d-5a198a7f2f83
reward-commands: []
```

Wartości "lista-minecraft" czy "lista-serwerow-emecz" mogą być czymkolwiek - są to tylko nazwy. Nazwy powinny być
unikatowe dla każdego serwera. Można dodać tyle serwerów, ile jest potrzebne.
[English](README.md)

`address` odnosi się do adresu strony, na której dodano serwer. Wspierane adresy to:
Plugin nagradzający graczy za głosowanie na serwer na listach serwerów
([lista-minecraft.pl](https://lista-minecraft.pl), [lista-serwerow.emecz.pl](https://lista-serwerow.emecz.pl),
[minecraft-list.info](https://minecraft-list.info)). Co 30 sekund (konfigurowalne) sprawdza nowe głosy przez API
list i automatycznie wykonuje komendy nagród — od razu, albo przy najbliższym wejściu gracza na serwer.

- https://lista-minecraft.pl,
- https://lista-serwerow.emecz.pl,
- https://minecraft-list.info.
- **Minecraft:** 1.18 – 26.3
- **Silniki:** Spigot, Paper, Purpur, Folia i inne zgodne z Bukkit API (szczegóły w [instalacji](docs/pl/installation.md#obsługiwane-serwery))
- **Java:** 17+ (taka, jakiej wymaga wersja Minecrafta)
- Statystyki: [bStats](https://bstats.org/plugin/bukkit/VoteReward/20120)

`uuid` oznacza unikatowe ID serwera przypisane wyłącznie do niego. Aby sprawdzić ID, należy wejść na stronę serwera i
skopiować ostatni element adresu strony. Przykładowo, jeżeli wygląda on
następująco: https://lista-minecraft.pl/serwery/minecraft/183413bc-4588-4265-8f06-346963e5d7df - ID będzie
równe `183413bc-4588-4265-8f06-346963e5d7df`.
## Dokumentacja

`reward-commands` to lista komend, które zostaną wysłane do konsoli serwera po pomyślnym zweryfikowaniu głosu gracza.
Dostępne są następujące symbole zastępcze (placeholdery):
| | |
|---|---|
| [Instalacja](docs/pl/installation.md) | wymagania, obsługiwane serwery, aktualizacja z 3.x |
| [Konfiguracja](docs/pl/configuration.md) | `settings.yml`, `messages.yml`, komendy i uprawnienia |
| [Jak to działa](docs/pl/architecture.md) | odpytywanie API, zasady nagród, struktura kodu |
| [Development](docs/pl/development.md) | budowanie, Docker, serwer testowy z atrapą API |
| [Testy](docs/pl/testing.md) | uruchamianie testów, co jest testowane, jak pisać nowe |
| [Release](docs/pl/release.md) | wydawanie nowej wersji |

- `%player_name%` - nazwa gracza,
- `%player_display_name%` - wyświetlana nazwa gracza,
- `%player_uuid%` - unikatowe ID gracza,
- `%server_name%` - nazwa serwera,
- `%server_address%` - adres strony serwera.
## Szybki start

Jeżeli plugin został poprawnie skonfigurowany, gracz po oddaniu głosu może użyć komendy `/votereward`, aby otrzymać
nagrodę za głosowanie.
1. Pobierz `VoteReward-<wersja>.jar` z [Releases](https://github.com/dudekm/VoteReward/releases/latest) i wrzuć do `plugins/`.
2. Uruchom serwer, a potem w `plugins/VoteReward/settings.yml` wpisz `uuid` swojego serwera z każdej listy i komendy nagród.
3. `/votereward reload`.
75 changes: 22 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,30 @@
The Polish version can be found [here](README-PL.md).

# VoteReward

VoteReward is a Spigot plugin that allows you to award players rewards for voting on a server. It was created for
versions above 1.18. Project statistics available on the [bStats](https://bstats.org/plugin/bukkit/VoteReward/20120)
website.

# Installation

Download the latest version of the plugin [here](https://github.com/dudekm/VoteReward/releases/latest).

After downloading the `.jar` file, place it in the "plugins" folder in the main server directory and then restart the
server. After restarting, a "VoteReward" folder should be created containing the configuration file.

Now in `settings.yml` you need to configure the servers that players can vote for. To do this, go to the `servers`
section. Its default form looks like this:

```yaml
servers:
lista-minecraft:
address: https://lista-minecraft.pl
uuid: 183413bc-4588-4265-8f06-346963e5d7df
reward-commands:
- xp add %player_name% 100
- give %player_name% diamond
lista-serwerow-emecz:
address: https://lista-serwerow.emecz.pl
uuid: 264acafc-136c-4def-a363-088587c7a405
reward-commands: []
minecraft-list:
address: https://minecraft-list.info
uuid: d6dfe480-da3a-495a-a92d-5a198a7f2f83
reward-commands: []
```

The values "lista-minecraft" or "lista-serwerow-emecz" can be anything - they are just names. Names should be unique for
each server. As many servers can be added as needed.
[Polski](README-PL.md)

`address` refers to the address of the page where the server was added. Supported addresses are:
A plugin that rewards players for voting for your server on server lists
([lista-minecraft.pl](https://lista-minecraft.pl), [lista-serwerow.emecz.pl](https://lista-serwerow.emecz.pl),
[minecraft-list.info](https://minecraft-list.info)). Every 30 seconds (configurable) it checks the lists' APIs for new
votes and automatically runs the reward commands — right away, or the next time the player joins the server.

- https://lista-minecraft.pl,
- https://lista-serwerow.emecz.pl,
- https://minecraft-list.info.
- **Minecraft:** 1.18 – 26.3
- **Server software:** Spigot, Paper, Purpur, Folia and others compatible with the Bukkit API (see [installation](docs/installation.md#supported-servers))
- **Java:** 17+ (whatever your Minecraft version requires)
- Statistics: [bStats](https://bstats.org/plugin/bukkit/VoteReward/20120)

`uuid` means a unique server ID assigned exclusively to it. To check the ID, go to the server's website and copy the
last element of the website address. For example, if it looks like
this: https://lista-minecraft.pl/serwery/minecraft/183413bc-4588-4265-8f06-346963e5d7df - the ID will
be `183413bc-4588-4265-8f06-346963e5d7df`.
## Documentation

`reward-commands` is a list of commands that will be sent to the server console after the player's vote has been
successfully verified. The following placeholders are available:
| | |
|---|---|
| [Installation](docs/installation.md) | requirements, supported servers, upgrading from 3.x |
| [Configuration](docs/configuration.md) | `settings.yml`, `messages.yml`, commands and permissions |
| [How it works](docs/architecture.md) | API polling, reward rules, code structure |
| [Development](docs/development.md) | building, Docker, test server with a mock API |
| [Testing](docs/testing.md) | running tests, what is covered, writing new ones |
| [Release](docs/release.md) | publishing a new version |

- `%player_name%` - name of the player,
- `%player_display_name%` - display name of the player,
- `%player_uuid%` - unique player ID,
- `%server_name%` - server name,
- `%server_address%` - server page address.
## Quick start

If the plugin has been configured correctly, after voting, the player can use the `/votereward` command to receive the
vote reward.
1. Download `VoteReward-<version>.jar` from [Releases](https://github.com/dudekm/VoteReward/releases/latest) and put it in `plugins/`.
2. Start the server, then in `plugins/VoteReward/settings.yml` enter your server's `uuid` from each list and the reward commands.
3. Run `/votereward reload`.
53 changes: 53 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Local development. See docs/development.md.
#
# docker compose run --rm build # tests + jar, copied to docker/plugins/
# docker compose up -d minecraft # test server with the plugin + mock vote list
# docker compose logs -f minecraft
#
# Server type and version: MC_TYPE (PAPER, SPIGOT, PURPUR, FOLIA…), MC_VERSION (1.18.2 … 26.3),
# MC_JAVA — the image's Java tag: java17 for 1.18–1.20.4, java21 for 1.20.5–1.21.x, java25 for 26.x.
# MC_TYPE=SPIGOT MC_VERSION=1.18.2 MC_JAVA=java17 docker compose up -d minecraft

services:
build:
build: .
volumes:
- ./:/workspace
- maven-cache:/root/.m2
command: >
sh -c "mvn -B verify && cp target/VoteReward-*.jar docker/plugins/VoteReward.jar"

# Imitates GET /api/v1/servers/{uuid}/votes of the vote lists.
# Edit docker/mock-api/mappings/votes.json, then: curl -X POST localhost:8089/__admin/mappings/reset
mock-api:
image: wiremock/wiremock:3.13.1
command: ["--global-response-templating", "--verbose"]
ports:
- "8089:8080"
volumes:
- ./docker/mock-api:/home/wiremock

minecraft:
image: itzg/minecraft-server:${MC_JAVA:-java25}
depends_on:
- mock-api
environment:
EULA: "TRUE"
TYPE: ${MC_TYPE:-PAPER}
VERSION: ${MC_VERSION:-LATEST}
# Lets you join under the nickname from the mock vote (DevPlayer) without a Mojang account.
ONLINE_MODE: "FALSE"
MEMORY: 2G
# Copies docker/plugins (the jar and settings.yml pointing at the mock) into the server.
COPY_PLUGINS_SRC: /plugins
ports:
- "25565:25565"
volumes:
- ./docker/plugins:/plugins:ro
- minecraft-data:/data
stdin_open: true
tty: true

volumes:
maven-cache:
minecraft-data:
56 changes: 0 additions & 56 deletions dependency-reduced-pom.xml

This file was deleted.

31 changes: 31 additions & 0 deletions docker/mock-api/mappings/votes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"request": {
"method": "GET",
"urlPathPattern": "/api/v1/servers/[0-9a-fA-F-]+/votes"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/ld+json; charset=utf-8"
},
"jsonBody": {
"@context": "/api/v1/contexts/Vote",
"@id": "/api/v1/servers/00000000-0000-0000-0000-000000000000/votes",
"@type": "Collection",
"totalItems": 1,
"member": [
{
"@id": "/api/v1/votes/7d4c3f8e-0000-4000-8000-000000000001",
"@type": "Vote",
"uuid": "7d4c3f8e-0000-4000-8000-000000000001",
"nickname": "DevPlayer",
"createdAt": "{{now}}"
}
],
"view": {
"@id": "/api/v1/servers/00000000-0000-0000-0000-000000000000/votes",
"@type": "PartialCollectionView"
}
}
}
}
Loading
Loading