Skip to content

Commit 55f3d61

Browse files
committed
Merge remote-tracking branch 'upstream/minor-next' into creativeDrop
2 parents b02bcaf + 371eccd commit 55f3d61

File tree

1,567 files changed

+66497
-26540
lines changed

Some content is hidden

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

1,567 files changed

+66497
-26540
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ Requires translations:
3434

3535
## Tests
3636
<!--
37-
Details should be provided of tests done. Simply saying "tested" or equivalent is not acceptable.
38-
39-
Attach scripts or actions to test this pull request, as well as the result
37+
PRs which have not been tested MUST be marked as draft.
4038
-->
39+
I tested this PR by doing the following (tick all that apply):
40+
- [ ] Writing PHPUnit tests (commit these in the `tests/phpunit` folder)
41+
- [ ] Playtesting using a Minecraft client (provide screenshots or a video)
42+
- [ ] Writing a test plugin (provide the code and sample output)
43+
- [ ] Other (provide details)

.github/dependabot.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ updates:
33
- package-ecosystem: composer
44
directory: "/"
55
schedule:
6-
interval: daily
6+
interval: weekly
77
time: "10:00"
88
open-pull-requests-limit: 10
9+
ignore:
10+
#only allow patch updates for locale-data - this has to be updated manually due to codegen
11+
- dependency-name: pocketmine/locale-data
12+
update-types:
13+
- "version-update:semver-major"
14+
- "version-update:semver-minor"
15+
16+
- package-ecosystem: gitsubmodule
17+
directory: "/"
18+
schedule:
19+
interval: daily
20+
21+
- package-ecosystem: github-actions
22+
directory: "/"
23+
schedule:
24+
interval: weekly
1.88 KB
Loading
1.75 KB
Loading
173 KB
Loading

.github/readme/pocketmine-rgb.gif

173 KB
Loading
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Update Docker Hub images
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
name: Update Docker Hub images
11+
runs-on: ubuntu-20.04
12+
13+
steps:
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Login to DockerHub
18+
uses: docker/login-action@v3
19+
with:
20+
username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_TOKEN }}
22+
23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Clone pmmp/PocketMine-Docker repository
31+
uses: actions/checkout@v4
32+
with:
33+
repository: pmmp/PocketMine-Docker
34+
fetch-depth: 1
35+
36+
- name: Get tag names
37+
id: tag-name
38+
run: |
39+
VERSION=$(echo "${{ github.ref }}" | sed 's{^refs/tags/{{')
40+
echo TAG_NAME=$VERSION >> $GITHUB_OUTPUT
41+
echo MAJOR=$(echo $VERSION | cut -d. -f1) >> $GITHUB_OUTPUT
42+
echo MINOR=$(echo $VERSION | cut -d. -f1-2) >> $GITHUB_OUTPUT
43+
44+
- name: Download new release information
45+
run: curl -f -L ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.tag-name.outputs.TAG_NAME }}/build_info.json -o new_build_info.json
46+
47+
- name: Detect channel
48+
id: channel
49+
run: echo CHANNEL=$(jq -r '.channel' new_build_info.json) >> $GITHUB_OUTPUT
50+
51+
- name: Get name of Docker repository name
52+
id: docker-repo-name
53+
run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT
54+
55+
- name: Build image for tag
56+
uses: docker/[email protected]
57+
with:
58+
push: true
59+
context: ./pocketmine-mp
60+
tags: |
61+
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.TAG_NAME }}
62+
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.TAG_NAME }}
63+
build-args: |
64+
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
65+
PMMP_REPO=${{ github.repository }}
66+
67+
- name: Build image for major tag
68+
if: steps.channel.outputs.CHANNEL == 'stable'
69+
uses: docker/[email protected]
70+
with:
71+
push: true
72+
context: ./pocketmine-mp
73+
tags: |
74+
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.MAJOR }}
75+
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.MAJOR }}
76+
build-args: |
77+
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
78+
PMMP_REPO=${{ github.repository }}
79+
80+
- name: Build image for minor tag
81+
if: steps.channel.outputs.CHANNEL == 'stable'
82+
uses: docker/[email protected]
83+
with:
84+
push: true
85+
context: ./pocketmine-mp
86+
tags: |
87+
${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.MINOR }}
88+
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:${{ steps.tag-name.outputs.MINOR }}
89+
build-args: |
90+
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
91+
PMMP_REPO=${{ github.repository }}
92+
93+
- name: Build image for latest tag
94+
if: steps.channel.outputs.CHANNEL == 'stable'
95+
uses: docker/[email protected]
96+
with:
97+
push: true
98+
context: ./pocketmine-mp
99+
tags: |
100+
${{ steps.docker-repo-name.outputs.NAME }}:latest
101+
ghcr.io/${{ steps.docker-repo-name.outputs.NAME }}:latest
102+
build-args: |
103+
PMMP_TAG=${{ steps.tag-name.outputs.TAG_NAME }}
104+
PMMP_REPO=${{ github.repository }}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace pocketmine;
6+
7+
use pocketmine\utils\Internet;
8+
use function dirname;
9+
use function fwrite;
10+
use function is_array;
11+
use function json_decode;
12+
use function json_encode;
13+
use const JSON_THROW_ON_ERROR;
14+
use const STDERR;
15+
16+
require dirname(__DIR__, 2) . '/vendor/autoload.php';
17+
18+
/**
19+
* @phpstan-return array<string, mixed>
20+
*/
21+
function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl, int $newsPingRoleId, ?string $phpDownloadUrl) : array{
22+
if($phpDownloadUrl !== null){
23+
$phpEmbedLink = " | [PHP Binaries]($phpDownloadUrl)";
24+
}else{
25+
$phpEmbedLink = "";
26+
}
27+
return [
28+
"content" => "<@&$newsPingRoleId> New PocketMine-MP release: $version ($channel)",
29+
"embeds" => [
30+
[
31+
"title" => "New PocketMine-MP release: $version ($channel)",
32+
"description" => <<<DESCRIPTION
33+
$description
34+
35+
[Details]($detailsUrl) | [Source Code]($sourceUrl) | [Build Log]($buildLogUrl) | [Download]($pharDownloadUrl)$phpEmbedLink
36+
DESCRIPTION,
37+
"url" => $detailsUrl,
38+
"color" => $channel === "stable" ? 0x57ab5a : 0xc69026
39+
]
40+
]
41+
];
42+
}
43+
44+
if(count($argv) !== 6){
45+
fwrite(STDERR, "Required arguments: github repo, version, API token, webhook URL, ping role ID\n");
46+
exit(1);
47+
}
48+
[, $repo, $tagName, $token, $hookURL, $newsPingRoleId] = $argv;
49+
50+
$result = Internet::getURL('https://api.github.com/repos/' . $repo . '/releases/tags/' . $tagName, extraHeaders: [
51+
'Authorization: token ' . $token
52+
]);
53+
if($result === null){
54+
fwrite(STDERR, "failed to access GitHub API\n");
55+
return;
56+
}
57+
if($result->getCode() !== 200){
58+
fwrite(STDERR, "Error accessing GitHub API: " . $result->getCode() . "\n");
59+
fwrite(STDERR, $result->getBody() . "\n");
60+
exit(1);
61+
}
62+
63+
$releaseInfoJson = json_decode($result->getBody(), true, JSON_THROW_ON_ERROR);
64+
if(!is_array($releaseInfoJson)){
65+
fwrite(STDERR, "Invalid release JSON returned from GitHub API\n");
66+
exit(1);
67+
}
68+
$buildInfoPath = 'https://github.com/' . $repo . '/releases/download/' . $tagName . '/build_info.json';
69+
70+
$buildInfoResult = Internet::getURL($buildInfoPath, extraHeaders: [
71+
'Authorization: token ' . $token
72+
]);
73+
if($buildInfoResult === null){
74+
fwrite(STDERR, "missing build_info.json\n");
75+
exit(1);
76+
}
77+
if($buildInfoResult->getCode() !== 200){
78+
fwrite(STDERR, "error accessing build_info.json: " . $buildInfoResult->getCode() . "\n");
79+
fwrite(STDERR, $buildInfoResult->getBody() . "\n");
80+
exit(1);
81+
}
82+
83+
$buildInfoJson = json_decode($buildInfoResult->getBody(), true, JSON_THROW_ON_ERROR);
84+
if(!is_array($buildInfoJson)){
85+
fwrite(STDERR, "invalid build_info.json\n");
86+
exit(1);
87+
}
88+
$detailsUrl = $buildInfoJson["details_url"];
89+
$sourceUrl = $buildInfoJson["source_url"];
90+
$pharDownloadUrl = $buildInfoJson["download_url"];
91+
$buildLogUrl = $buildInfoJson["build_log_url"];
92+
$phpBinaryUrl = $buildInfoJson["php_download_url"] ?? null;
93+
94+
$description = $releaseInfoJson["body"];
95+
96+
$discordPayload = generateDiscordEmbed(
97+
$buildInfoJson["base_version"],
98+
$buildInfoJson["channel"],
99+
$description,
100+
$detailsUrl,
101+
$sourceUrl,
102+
$pharDownloadUrl,
103+
$buildLogUrl,
104+
(int) $newsPingRoleId,
105+
$phpBinaryUrl
106+
);
107+
108+
$response = Internet::postURL(
109+
$hookURL,
110+
json_encode($discordPayload, JSON_THROW_ON_ERROR),
111+
extraHeaders: ['Content-Type: application/json']
112+
);
113+
if($response?->getCode() !== 204){
114+
fwrite(STDERR, "failed to send Discord webhook\n");
115+
fwrite(STDERR, $response?->getBody() ?? "no response body\n");
116+
exit(1);
117+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Notify Discord webhook of release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup PHP and tools
16+
uses: shivammathur/[email protected]
17+
with:
18+
php-version: 8.2
19+
20+
- name: Restore Composer package cache
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.cache/composer/files
25+
~/.cache/composer/vcs
26+
key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}"
27+
restore-keys: |
28+
composer-v2-cache-
29+
30+
- name: Install Composer dependencies
31+
run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs
32+
33+
- name: Get actual tag name
34+
id: tag-name
35+
run: echo TAG_NAME=$(echo "${{ github.ref }}" | sed 's{^refs/tags/{{') >> $GITHUB_OUTPUT
36+
37+
- name: Run webhook post script
38+
run: php .github/workflows/discord-release-embed.php ${{ github.repository }} ${{ steps.tag-name.outputs.TAG_NAME }} ${{ github.token }} ${{ secrets.DISCORD_RELEASE_WEBHOOK }} ${{ secrets.DISCORD_NEWS_PING_ROLE_ID }}

.github/workflows/draft-release.yml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ jobs:
1111
runs-on: ubuntu-20.04
1212
strategy:
1313
fail-fast: false
14+
matrix:
15+
php-version: [8.2]
1416

1517
steps:
16-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1719
with:
1820
submodules: true
1921

2022
- name: Setup PHP
21-
uses: shivammathur/setup-php@2.12.0
23+
uses: shivammathur/setup-php@2.30.4
2224
with:
23-
php-version: 8.0
25+
php-version: ${{ matrix.php-version }}
2426

2527
- name: Restore Composer package cache
26-
uses: actions/cache@v2
28+
uses: actions/cache@v4
2729
with:
2830
path: |
2931
~/.cache/composer/files
@@ -40,7 +42,7 @@ jobs:
4042
run: |
4143
BUILD_NUMBER=$((2000+$GITHUB_RUN_NUMBER)) #to stay above jenkins
4244
echo "Build number: $BUILD_NUMBER"
43-
echo ::set-output name=BUILD_NUMBER::$BUILD_NUMBER
45+
echo BUILD_NUMBER=$BUILD_NUMBER >> $GITHUB_OUTPUT
4446
4547
- name: Minify BedrockData JSON files
4648
run: php vendor/pocketmine/bedrock-data/.minify_json.php
@@ -51,16 +53,31 @@ jobs:
5153
- name: Get PocketMine-MP release version
5254
id: get-pm-version
5355
run: |
54-
echo ::set-output name=PM_VERSION::$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BASE_VERSION;')
55-
echo ::set-output name=MCPE_VERSION::$(php -r 'require "vendor/autoload.php"; echo \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK;')
56-
echo ::set-output name=PM_VERSION_SHORT::$(php -r 'require "vendor/autoload.php"; $v = explode(".", \pocketmine\VersionInfo::BASE_VERSION); array_pop($v); echo implode(".", $v);')
57-
echo ::set-output name=PM_VERSION_MD::$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);')
56+
echo PM_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BASE_VERSION;') >> $GITHUB_OUTPUT
57+
echo MCPE_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK;') >> $GITHUB_OUTPUT
58+
echo PM_VERSION_SHORT=$(php -r 'require "vendor/autoload.php"; $v = explode(".", \pocketmine\VersionInfo::BASE_VERSION); array_pop($v); echo implode(".", $v);') >> $GITHUB_OUTPUT
59+
echo PM_VERSION_MD=$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);') >> $GITHUB_OUTPUT
60+
echo CHANGELOG_SUFFIX=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "" : "-" . \pocketmine\VersionInfo::BUILD_CHANNEL;') >> $GITHUB_OUTPUT
61+
echo PRERELEASE=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "false" : "true";') >> $GITHUB_OUTPUT
62+
63+
- name: Generate PHP binary download URL
64+
id: php-binary-url
65+
run: |
66+
echo PHP_BINARY_URL="${{ github.server_url }}/${{ github.repository_owner }}/PHP-Binaries/releases/tag/php-${{ matrix.php-version }}-latest" >> $GITHUB_OUTPUT
5867
5968
- name: Generate build info
60-
run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} > build_info.json
69+
run: |
70+
php build/generate-build-info-json.php \
71+
${{ github.sha }} \
72+
${{ steps.get-pm-version.outputs.PM_VERSION }} \
73+
${{ github.repository }} \
74+
${{ steps.build-number.outputs.BUILD_NUMBER }} \
75+
${{ github.run_id }} \
76+
${{ steps.php-binary-url.outputs.PHP_BINARY_URL }} \
77+
> build_info.json
6178
6279
- name: Upload release artifacts
63-
uses: actions/upload-artifact@v2
80+
uses: actions/upload-artifact@v4
6481
with:
6582
name: release_artifacts
6683
path: |
@@ -69,15 +86,18 @@ jobs:
6986
${{ github.workspace }}/build_info.json
7087
7188
- name: Create draft release
72-
uses: ncipollo/release-action@v1.8.6
89+
uses: ncipollo/release-action@v1.14.0
7390
with:
7491
artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json
7592
commit: ${{ github.sha }}
7693
draft: true
94+
prerelease: ${{ steps.get-pm-version.outputs.PRERELEASE }}
7795
name: PocketMine-MP ${{ steps.get-pm-version.outputs.PM_VERSION }}
7896
tag: ${{ steps.get-pm-version.outputs.PM_VERSION }}
7997
token: ${{ secrets.GITHUB_TOKEN }}
8098
body: |
8199
**For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}**
82100
83-
Please see the [changelogs](/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details.
101+
Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}${{ steps.get-pm-version.outputs.CHANGELOG_SUFFIX }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details.
102+
103+
:information_source: Download the recommended PHP binary [here](${{ steps.php-binary-url.outputs.PHP_BINARY_URL }}).

0 commit comments

Comments
 (0)