Skip to content

Commit

Permalink
Add support for PocketMine-MP v4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMicky-FR committed Feb 6, 2022
1 parent 63268ce commit f373830
Show file tree
Hide file tree
Showing 11 changed files with 1,577 additions and 395 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

# Composer
vendor/

# Build
build/
62 changes: 62 additions & 0 deletions build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

error_reporting(E_ALL | E_STRICT);

if (ini_get('phar.readonly')) {
exit('You need to enable phar creation in the php.ini by disabling "phar.readonly".'.PHP_EOL);
}

if (is_dir(__DIR__.'/vendor/pocketmine/pocketmine-mp')) {
exit('You need to uninstall dev dependencies with "composer install --no-dev".'.PHP_EOL);
}

$description = file_get_contents(__DIR__.'/plugin.yml');
$buildDir = __DIR__.'/build';

if ($description === false) {
exit('Unable to read plugin.yml file.'.PHP_EOL);
}

if (! is_dir($buildDir) && ! mkdir($buildDir) && ! is_dir($buildDir)) {
exit('Unable to create the build/ directory.'.PHP_EOL);
}

preg_match('/^version: ?(.+)$/m', $description, $matches);
$pharPath = "build/AzLink-PocketMine-{$matches[1]}.phar";

if (file_exists($pharPath)) {
unlink($pharPath);
}

$phar = new Phar($pharPath);
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->startBuffering();

$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(__DIR__),
);
$phar->buildFromIterator(new class($iterator) extends FilterIterator {
public function accept(): bool
{
$current = $this->getInnerIterator()->current();

if (is_dir($current)) {
return false;
}

$current = substr($current, strlen(__DIR__) + 1);

if (DIRECTORY_SEPARATOR !== '/') { // Windows uses '\\' instead of '/'
$current = str_replace(DIRECTORY_SEPARATOR, '/', $current);
}

return $current === 'plugin.yml'
|| str_starts_with($current, 'src/')
|| str_starts_with($current, 'vendor/');
}
}, __DIR__);

$phar->stopBuffering();
$phar->compressFiles(Phar::GZ);

exit('PHAR successfully created.'.PHP_EOL);
23 changes: 16 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
{
"name": "azuriom/azlink-pocketmine",
"require": {
"php": "^7.1",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0"
"php": "^8.0",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
"phpstan/phpstan": "^0.12.18",
"pocketmine/pocketmine-mp": "^3.0",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpstan/phpstan": "^1.2.0",
"pocketmine/pocketmine-mp": "^4.0.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/extension-installer": "^1.0"
},
"autoload": {
"psr-4": {
"\\": "src/"
"Azuriom\\AzLink\\PocketMine\\": "src/"
}
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"provide": {
"ext-chunkutils2": "*",
"ext-crypto": "*",
"ext-igbinary": "*",
"ext-leveldb": "*",
"ext-morton": "*",
"ext-pthreads": "*",
"ext-sockets": "*",
"ext-yaml": "*"
Expand Down
Loading

0 comments on commit f373830

Please sign in to comment.