|
1 | | -# ImageOnMap |
2 | | - 🖼️ Easy to use PocketMine plugin, which allows loading images on maps |
| 1 | +<h1>ImageOnMap</h1> |
| 2 | +<a href="https://poggit.pmmp.io/ci/CzechPMDevs/ImageOnMap/ImageOnMap"> |
| 3 | + <img src="https://poggit.pmmp.io/ci.shield/CzechPMDevs/ImageOnMap/ImageOnMap?style=flat-square"> |
| 4 | +</a> |
| 5 | +<a href="https://discord.gg/uwBf2jS"> |
| 6 | + <img src="https://img.shields.io/discord/365202594932719616.svg?style=flat-square"> |
| 7 | +</a> |
| 8 | +<a href="https://github.com/CzechPMDevs/ImageOnMap/releases"> |
| 9 | + <img src="https://img.shields.io/github/release/CzechPMDevs/ImageOnMap.svg?style=flat-square"> |
| 10 | +</a> |
| 11 | +<a href="https://github.com/CzechPMDevs/ImageOnMap/releases"> |
| 12 | + <img src="https://img.shields.io/github/downloads/CzechPMDevs/ImageOnMap/total.svg?style=flat-square"> |
| 13 | +</a> |
| 14 | +<a href="https://github.com/CzechPMDevs/ImageOnMap/blob/master/LICENSE"> |
| 15 | + <img src="https://img.shields.io/github/license/CzechPMDevs/ImageOnMap.svg?style=flat-square"> |
| 16 | +</a> |
| 17 | +<a href="https://poggit.pmmp.io/p/ImageOnMap"> |
| 18 | + <img src="https://poggit.pmmp.io/shield.downloads/ImageOnMap?style=flat-square"> |
| 19 | +</a> |
| 20 | +<br><br> |
| 21 | +✔️ Simple usage, without external convertors |
| 22 | +<br> |
| 23 | +✔️ Supporting both .png and .jpg image formats |
| 24 | +<br> |
| 25 | +✔️ Image is automatically resized to fit item frame |
| 26 | +<br> |
| 27 | +✔️ Supports last PocketMine API version |
| 28 | +<br> |
| 29 | + |
| 30 | +## Commands |
| 31 | + |
| 32 | +- Plugin implements command `/image` with aliases `/img` and `/iom`. |
| 33 | +- To use this command, **permission** `imageonmap.command` **is needed**. |
| 34 | +- This command can be used only in game. |
| 35 | + <br> |
| 36 | +- There are implemented these subcommands: |
| 37 | + |
| 38 | +| **Sub-Command** | **Description** | |
| 39 | +|---|---| |
| 40 | +| /img help | Shows all the available subcommands | |
| 41 | +| /img list | Displays all the available images found in `/plugin_data/ImageOnMap/images/*` path. | |
| 42 | +| /img obtain `<image>` `[<xChunkCount> <yChunkCount> <x> <y>]` | Obtains specific image (or it's specific part) from file as map item.<br><br>Chunk count argument represents to how many parts should be the image split. X and Y coordinates represents which part of that chunked image will be given to player's inventory.<br><br>Aliases: /img o | |
| 43 | +| /img place `<image>` | Places the whole images on to item frames in selected area.<br><br>To place an image properly, first execute the command (`/img p image`). Afterwards, break the first corner of the target position and then break the block to select second position. The image will be placed automatically.<br><br>Aliases: /img p | |
| 44 | + |
| 45 | +## API |
| 46 | + |
| 47 | +- Obtaining plugin instance |
| 48 | + |
| 49 | +```php |
| 50 | +$api = \czechpmdevs\imageonmap\ImageOnMap::getInstance(); |
| 51 | +``` |
| 52 | + |
| 53 | +- Loading image from file |
| 54 | + |
| 55 | +```php |
| 56 | +// This method caches the map and returns its id. Afterwards the id can be used to obtain map item. |
| 57 | +$id = $api->getImageFromFile( |
| 58 | + file: "path/to/image.png", |
| 59 | + xChunkCount: 1, |
| 60 | + yChunkCount: 1, |
| 61 | + xOffset: 0, |
| 62 | + yOffset: 0 |
| 63 | +); |
| 64 | +``` |
| 65 | + |
| 66 | +- Obtaining Map item, assigning id & giving it to player |
| 67 | + |
| 68 | +```php |
| 69 | +/** @var \czechpmdevs\imageonmap\item\FilledMap $map */ |
| 70 | +$map = (FilledMap::get())->setMapId($id); |
| 71 | +/** @var \pocketmine\player\Player $player */ |
| 72 | +$player->getInventory()->addItem($map); |
| 73 | +``` |
0 commit comments