Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VixikHD committed Aug 27, 2021
0 parents commit 0cc37ac
Show file tree
Hide file tree
Showing 21 changed files with 5,235 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendor
out
.idea
*.jpg
*.png
test.php
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.0.8","version":"3.0.2:v3.0.2#990b979379502feb7f393d6c9aa36cc9b9765f24","indent":"\t","lineEnding":"\n","rules":{"align_multiline_comment":{"comment_type":"phpdocs_only"},"array_indentation":true,"array_syntax":{"syntax":"short"},"blank_line_after_namespace":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["declare"]},"cast_spaces":{"space":"single"},"concat_space":{"spacing":"one"},"declare_strict_types":true,"elseif":true,"global_namespace_import":{"import_constants":true,"import_functions":true,"import_classes":null},"indentation_type":true,"native_function_invocation":{"scope":"namespaced"},"no_closing_tag":true,"no_empty_phpdoc":true,"no_extra_blank_lines":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true},"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"no_whitespace_in_blank_line":true,"no_unused_imports":true,"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"single_import_per_statement":true,"strict_param":true},"hashes":{"src\\czechpmdevs\\imageonmap\\command\\ImageCommand.php":155313621,"src\\czechpmdevs\\imageonmap\\DataProviderTrait.php":38430561,"src\\czechpmdevs\\imageonmap\\ImageOnMap.php":3204124079,"src\\czechpmdevs\\imageonmap\\item\\FilledMap.php":3385871992,"src\\czechpmdevs\\imageonmap\\UnknownMapIdException.php":3847852575,"src\\czechpmdevs\\imageonmap\\utils\\ColorSerializer.php":3075177427,"src\\czechpmdevs\\imageonmap\\utils\\Image.php":2265461095,"src\\czechpmdevs\\imageonmap\\utils\\ImageLoader.php":2953570286}}
64 changes: 64 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

$finder = PhpCsFixer\Finder::create()->in(__DIR__ . '/src');

return (new PhpCsFixer\Config)
->setRiskyAllowed(true)
->setRules([
'align_multiline_comment' => [
'comment_type' => 'phpdocs_only'
],
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short'
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => [
'declare'
]
],
'cast_spaces' => [
'space' => 'single'
],
'concat_space' => [
'spacing' => 'one'
],
'declare_strict_types' => true,
'elseif' => true,
'global_namespace_import' => [
'import_constants' => true,
'import_functions' => true,
'import_classes' => null,
],
'indentation_type' => true,
'native_function_invocation' => [
'scope' => 'namespaced'
],
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_extra_blank_lines' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_whitespace_in_blank_line' => true,
'no_unused_imports' => true,
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha'
],
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'single_import_per_statement' => true,
'strict_param' => true,
])
->setFinder($finder)
->setIndent("\t")
->setLineEnding("\n");
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ImageOnMap
🖼️ Easy to use PocketMine plugin, which allows loading images on maps
104 changes: 104 additions & 0 deletions build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

//exec("vendor\bin\php-cs-fixer.bat");

/**
* Build script
*/

// For example C:/pmmp-server/plugins/BuilderTools.phar
const CUSTOM_OUTPUT_PATH = "C:\Users\stehl\Desktop\pmmp\plugins\ImageOnMap.phar";
const COMPRESS_FILES = true;
const COMPRESSION = Phar::GZ;

$startTime = microtime(true);

// Input & Output directory...
$from = getcwd() . DIRECTORY_SEPARATOR;
$to = getcwd() . DIRECTORY_SEPARATOR . "out" . DIRECTORY_SEPARATOR . "ImageOnMap" . DIRECTORY_SEPARATOR;

@mkdir($to, 0777, true);

// Clean output directory...
cleanDirectory($to);

// Copying new files...
copyDirectory($from . "src", $to . "src");
//copyDirectory($from . "resources", $to . "resources");

$description = yaml_parse_file($from . "plugin.yml");
yaml_emit_file($to . "plugin.yml", $description);

// Defining output path...
$outputPath = CUSTOM_OUTPUT_PATH == "" ? getcwd() . DIRECTORY_SEPARATOR . "out" . DIRECTORY_SEPARATOR . "ImageOnMap_{$description["version"]}_dev.phar" : CUSTOM_OUTPUT_PATH;
@unlink($outputPath);

// Generate phar
$phar = new Phar($outputPath);
$phar->buildFromDirectory($to);

if(COMPRESS_FILES) {
$phar->compressFiles(COMPRESSION);
}

printf("Plugin built in %s seconds! Output path: %s\n", round(microtime(true) - $startTime, 3), $outputPath);

function copyDirectory(string $from, string $to): void {
mkdir($to, 0777, true);

$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($from, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
/** @var SplFileInfo $fileInfo */
foreach ($files as $fileInfo) {
$target = str_replace($from, $to, $fileInfo->getPathname());
if($fileInfo->isDir()) {
mkdir($target, 0777, true);
} else {
$contents = file_get_contents($fileInfo->getPathname());
preProcess($contents);
file_put_contents($target, $contents);
}
}
}

function cleanDirectory(string $directory): void {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
/** @var SplFileInfo $fileInfo */
foreach ($files as $fileInfo) {
if($fileInfo->isDir()) {
rmdir($fileInfo->getPathname());
} else {
unlink($fileInfo->getPathname());
}
}
}

function preProcess(string &$file): void {
// if(!defined("replacements")) {
// $patterns = [
// 'Math::lengthSquared2d({%1}, {%2})' => '({%1} ** 2) + ({%2} ** 2)',
// 'Math::lengthSquared3d({%1}, {%2}, {%3})' => '({%1} ** 2) + ({%2} ** 2) + ({%3} ** 2)',
// ];
//
// $replacements = [];
//
// foreach ($patterns as $key => $value) {
// $key = "#" . str_replace(["(", ")"], ["\(", "\)"], $key) . "#";
//
// /** @noinspection PhpStatementHasEmptyBodyInspection */
// for($i = 0; strpos($key, "{%" . (++$i) ."}") !== false;);
//
// for($j = 1; $j < $i; ++$j) {
// $key = str_replace("{%$j}", "(.*?)", $key);
// $value = str_replace("{%$j}", "\$$j", $value);
// }
//
// $replacements[$key] = $value;
// }
//
// define("replacements", $replacements);
// }
//
// $file = preg_replace(array_keys(replacements), array_values(replacements), $file);
}
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "czechpmdevs/imageonmap",
"description": "PocketMine plugin which allows to add images to map items",
"minimum-stability": "dev",
"license": "GPL-3.0-only",
"require": {
"php": "^8.0",
"ext-yaml": "*",
"ext-pthreads": "*",
"ext-json": "*",
"pocketmine/pocketmine-mp": "dev-master",
"ext-gd": "*"
},
"require-dev": {
"phpstan/phpstan": "0.12.83"
},
"autoload": {
"psr-4": {
"": ["src"]
}
}
}
Loading

0 comments on commit 0cc37ac

Please sign in to comment.