Skip to content

Commit c3062d0

Browse files
committed
Allow NG-PM fork to work
1 parent ab3ab2d commit c3062d0

16 files changed

+132
-45
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "composer"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"

.github/workflows/automerge.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Auto Merge Dependabot
2+
3+
on:
4+
pull_request:
5+
types: [assigned, opened, synchronize, reopened]
6+
jobs:
7+
automerge:
8+
runs-on: ubuntu-latest
9+
permissions: write-all
10+
steps:
11+
- id: automerge
12+
name: automerge
13+
uses: pascalgn/automerge-action@v0.15.6
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
MERGE_DELETE_BRANCH: true
17+
MERGE_FILTER_AUTHOR: dependabot[bot]
18+
MERGE_LABELS: ''
19+
MERGE_METHOD: squash

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PharBuilder
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: PharBuilder
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Download pharbuilder-rs
12+
uses: dsaltares/fetch-gh-release-asset@0.06
13+
with:
14+
file: pharbuilder
15+
repo: NetherGamesMC/pharbuilder-rs
16+
token: ${{ secrets.ng_token }}
17+
- name: Build
18+
run: |
19+
sudo chmod +x pharbuilder
20+
./pharbuilder -i . -o InvMenu.phar
21+
- name: Upload
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: InvMenu
25+
path: InvMenu.phar

.github/workflows/phpstan.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PHPStan CI
2+
3+
on: push
4+
5+
jobs:
6+
phpstan:
7+
name: PHPStan Analysis
8+
runs-on: ubuntu-latest
9+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
10+
steps:
11+
- name: Startup
12+
uses: actions/checkout@v4
13+
- name: Download PHP Release
14+
uses: dsaltares/fetch-gh-release-asset@1.1.1
15+
with:
16+
file: PHP-8.3-Linux-x86_64-PM5.tar.gz
17+
repo: NetherGamesMC/php-build-scripts
18+
version: "tags/pm5-php-8.3-latest"
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Unpack PHP Release
21+
run: tar -xzvf PHP-8.3-Linux-x86_64-PM5.tar.gz
22+
- name: Download Composer
23+
run: curl -o composer.phar "https://getcomposer.org/composer-stable.phar"
24+
- name: Add Composer GitHub access token
25+
run: ./bin/php7/bin/php composer.phar config --global github-oauth.github.com ${{ secrets.ng_token }}
26+
- name: Install Composer dependencies
27+
run: COMPOSER_ROOT_VERSION=dev-master ./bin/php7/bin/php composer.phar install --prefer-dist --no-interaction
28+
- name: Run PHPStan
29+
run: ./bin/php7/bin/php vendor/bin/phpstan.phar analyze --no-progress

composer.json

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
{
2-
"name": "muqsit/invmenu",
3-
"description": "A PocketMine-MP virion to create and manage virtual inventories!",
4-
"type": "library",
5-
"license": "GPL-3.0",
6-
"require": {
7-
"pocketmine/pocketmine-mp": "^5.0.0"
8-
},
9-
"autoload": {
10-
"classmap": ["src"]
11-
},
12-
"authors": [
13-
{
14-
"name": "Muqsit",
15-
"email": "hackhack05@gmail.com"
16-
}
17-
],
18-
"extra": {
19-
"virion": {
20-
"spec": "3.0",
21-
"namespace-root": "muqsit\\invmenu"
22-
}
23-
}
2+
"name": "nethergamesmc/invmenu",
3+
"description": "A PocketMine-MP virion to create and manage virtual inventories!",
4+
"license": "proprietary",
5+
"type": "project",
6+
"require": {
7+
"php": "^8.0"
8+
},
9+
"require-dev": {
10+
"phpstan/phpstan": "1.2.0",
11+
"nethergamesmc/pocketmine-mp": "dev-stable"
12+
},
13+
"repositories": [
14+
{ "type": "vcs", "url": "git@github.com:NetherGamesMC/PocketMine-MP.git" }
15+
],
16+
"autoload": {
17+
"classmap": ["src"]
18+
},
19+
"minimum-stability": "dev"
2420
}

phpstan.neon.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 6
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
5+
paths:
6+
- src

src/muqsit/invmenu/session/network/PlayerNetwork.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function dropPending() : void{
4444
* @param Closure(bool) : bool $then
4545
*/
4646
public function wait(int $type, Closure $then) : void{
47-
$entry = $this->handler->createNetworkStackLatencyEntry($then);
47+
$entry = $this->handler->createNetworkStackLatencyEntry($then, $this->network_session->getProtocolId());
4848
if($this->current !== null){
4949
$this->queue->enqueue($entry);
5050
}else{

src/muqsit/invmenu/session/network/handler/ClosurePlayerNetworkHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
final class ClosurePlayerNetworkHandler implements PlayerNetworkHandler{
1111

1212
/**
13-
* @param Closure(Closure) : NetworkStackLatencyEntry $creator
13+
* @param Closure(Closure, int) : NetworkStackLatencyEntry $creator
1414
*/
1515
public function __construct(
1616
readonly private Closure $creator
1717
){}
1818

19-
public function createNetworkStackLatencyEntry(Closure $then) : NetworkStackLatencyEntry{
20-
return ($this->creator)($then);
19+
public function createNetworkStackLatencyEntry(Closure $then, int $protocolId) : NetworkStackLatencyEntry{
20+
return ($this->creator)($then, $protocolId);
2121
}
2222
}

src/muqsit/invmenu/session/network/handler/PlayerNetworkHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
interface PlayerNetworkHandler{
1111

12-
public function createNetworkStackLatencyEntry(Closure $then) : NetworkStackLatencyEntry;
12+
public function createNetworkStackLatencyEntry(Closure $then, int $protocolId) : NetworkStackLatencyEntry;
1313
}

src/muqsit/invmenu/session/network/handler/PlayerNetworkHandlerRegistry.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Closure;
88
use muqsit\invmenu\session\network\NetworkStackLatencyEntry;
9+
use pocketmine\network\mcpe\protocol\ProtocolInfo;
910
use pocketmine\network\mcpe\protocol\types\DeviceOS;
1011
use function mt_rand;
1112

@@ -17,13 +18,13 @@ final class PlayerNetworkHandlerRegistry{
1718
private array $game_os_handlers = [];
1819

1920
public function __construct(){
20-
$this->registerDefault(new ClosurePlayerNetworkHandler(static function(Closure $then) : NetworkStackLatencyEntry{
21+
$this->registerDefault(new ClosurePlayerNetworkHandler(static function(Closure $then, int $protocolId) : NetworkStackLatencyEntry{
2122
$timestamp = mt_rand();
22-
return new NetworkStackLatencyEntry($timestamp * 1000000, $then, $timestamp);
23+
return new NetworkStackLatencyEntry($timestamp * ($protocolId >= ProtocolInfo::PROTOCOL_1_20_10 ? 1000000 : 1000), $then, $timestamp);
2324
}));
24-
$this->register(DeviceOS::PLAYSTATION, new ClosurePlayerNetworkHandler(static function(Closure $then) : NetworkStackLatencyEntry{
25+
$this->register(DeviceOS::PLAYSTATION, new ClosurePlayerNetworkHandler(static function(Closure $then, int $protocolId) : NetworkStackLatencyEntry{
2526
$timestamp = mt_rand();
26-
return new NetworkStackLatencyEntry($timestamp * 1000000, $then, $timestamp * 1000);
27+
return new NetworkStackLatencyEntry($timestamp * ($protocolId >= ProtocolInfo::PROTOCOL_1_20_10 ? 1000000 : 1), $then, $timestamp * 1000);
2728
}));
2829
}
2930

0 commit comments

Comments
 (0)