8 Commits

Author SHA1 Message Date
farcasclaudiu 7727a91d69 Upgrade version to 1.04 due submitted fix/release 2015-01-13 22:10:22 +02:00
farcasclaudiu 1d31b9e11d Merge pull request #1 from shoghicp/patch-1
Fixes "Too many open files"
2015-01-13 22:01:52 +02:00
Shoghi Cervantes 2a34b3f605 Fixes "Too many open files"
This fixes issues with not closing resources given by PocketMine, causing a crash at a later stage.
Users usually blame PocketMine for this, but it's entirely a plugin's fault.

This code was found via GitHub search, please review your code for usage of:

* `Plugin->getResource()` without `fclose()` calls later
* Not needed `Plugin->getResource()` calls
* `fopen()` calls without `fclose()`
* `popen()` calls without `pclose()`
2015-01-13 20:15:33 +01:00
farcasclaudiu d01098db1a version string 2015-01-11 09:35:51 +02:00
farcasclaudiu cb5037834d fix crash from back-slashes
fix crash from back-slashes
2015-01-08 22:23:46 +02:00
farcasclaudiu 23ebcce081 doc formatting 2015-01-08 12:17:21 +02:00
farcasclaudiu b52e8d3ecd v1.0.2 - implemented player teleportation nearby QR code panel
v1.0.2 - implemented player teleportation nearby QR code panel
2015-01-08 12:11:17 +02:00
farcasclaudiu 6563ba887c docs update 2015-01-05 16:52:47 +02:00
5 changed files with 64 additions and 27 deletions
+23 -14
View File
@@ -1,6 +1,6 @@
#QRcraft #QRcraft
Plugin for PocketMine-MP for creating QR panels (made from white and black wood blocks) Plugin for PocketMine-MP for creating QR code panels (made from white and black wool blocks)
Copyright (C) 2014 Clodyx <https://github.com/farcasclaudiu/QRcraft> Copyright (C) 2014 Clodyx <https://github.com/farcasclaudiu/QRcraft>
@@ -19,11 +19,11 @@ Plugin for PocketMine-MP for creating QR panels (made from white and black wood
ONLY OPs during gameplay (creative preferred) ONLY OPs during gameplay (creative preferred)
* `/qr` - shows help page * `/qr` - shows help page
* `/qrt <url>` - test QR text/url to count number of needed blocks (NxN) * `/qrt <url>` - test QR code text/url to count number of needed blocks (NxN)
* `/qrc <url> [Auto|horizontal|vertical]` - create QR panel/block * `/qrc <url> [Auto|horizontal|vertical]` - create QR code panel
* `/qrl` - list QR panels IDs * `/qrl` - list QR code panels IDs
* `/qrd <ID>` - delete QR panel by ID (fills panel space with air) * `/qrd <ID>` - delete QR code panel by ID (fills panel space with air)
* `/qrp <ID>` - teleport you nearby QR panel with specified ID (IN WORK) * `/qrp <ID>` - teleports the player nearby QR code panel with specified ID
Example: Example:
* `/qrt http://google.com` * `/qrt http://google.com`
@@ -32,23 +32,23 @@ Example:
``` ```
* `/qrc http://google.com` - begins the creation for specified url in auto mode * `/qrc http://google.com` - begins the creation for specified url in auto mode
``` ```
"QR block defined a (27x27) for 'http://google.com'" "QR panel defined a (27x27) for 'http://google.com'"
"Touch a block to create it!" "Touch a block to create it!"
- NOW the player has to touch another block to create the QR planel. - NOW the player has to touch another block to create the QR code panel.
- the new panel will be created above touched block and to the player right side. - the new panel will be created above touched block and to the player right side.
- in auto mode, is player is inclined forward pointing downwards, - in auto mode, is player is inclined forward pointing downwards,
the QR panel will be generated horizontally, the QR code panel will be generated horizontally,
otherwise it will be generated vertically. otherwise it will be generated vertically.
"QR block [1] created OK!" "QR panel [1] created OK!"
``` ```
* `/qrc http://google.com h` - begins the creation for specified url in horizontal mode * `/qrc http://google.com h` - begins the creation for specified url in horizontal mode
``` ```
"QR block defined h (27x27) for 'http://google.com'" "QR panel defined h (27x27) for 'http://google.com'"
"Touch a block to create it!" "Touch a block to create it!"
- now the player touches the block to build above. - now the player touches the block to build above.
"QR block [2] created OK!" "QR panel [2] created OK!"
``` ```
* `/qrl` - list current defined QR panels * `/qrl` - list current defined QR code panels
``` ```
"--------------" "--------------"
"QR LIST" "QR LIST"
@@ -61,9 +61,13 @@ Example:
``` ```
"QR panel [2] deleted." "QR panel [2] deleted."
``` ```
* `/qrp 2` - teleports the player nearby QR panel with ID 2
```
"You've been teleported nearby QR panel [2]."
```
## Configuration ## Configuration
No configuration needed for this moment. No configuration needed.
## Permissions ## Permissions
@@ -76,4 +80,9 @@ No configuration needed for this moment.
PocketMine-MP version min 1.0.0 PocketMine-MP version min 1.0.0
## Releases ## Releases
```
[1.0.3] - fix backslash crash
[1.0.2] - implemented teleport player nearby QR code panel
[1.0.1] - improvements
[1.0.0] - initial release [1.0.0] - initial release
```
+3 -3
View File
@@ -1,5 +1,5 @@
name: QRcraft name: QRcraft
version: 1.0.1 version: 1.0.4
api: 1.0.0 api: 1.0.0
main: clodyx\qrcraft\QRcraftPlugIn main: clodyx\qrcraft\QRcraftPlugIn
author: Clodyx author: Clodyx
@@ -18,10 +18,10 @@ commands:
description: "List QR panels IDs" description: "List QR panels IDs"
permission: clodyx.plugin.qrcraft permission: clodyx.plugin.qrcraft
qrd: qrd:
description: "delete QR panel by ID" description: "Delete QR panel by ID"
permission: clodyx.plugin.qrcraft permission: clodyx.plugin.qrcraft
qrp: qrp:
description: "teleport nearby QR panel by ID" description: "Teleport nearby QR panel by ID"
permission: clodyx.plugin.qrcraft permission: clodyx.plugin.qrcraft
permissions: permissions:
clodyx.plugin.qrcraft: clodyx.plugin.qrcraft:
+33 -2
View File
@@ -12,6 +12,7 @@ namespace clodyx\qrcraft;
use pocketmine\command\Command; use pocketmine\command\Command;
use pocketmine\command\CommandSender; use pocketmine\command\CommandSender;
use pocketmine\command\CommandExecutor; use pocketmine\command\CommandExecutor;
use pocketmine\math\Vector3;
use pocketmine\Player; use pocketmine\Player;
@@ -105,7 +106,37 @@ class QRcraftCommand
} }
break; break;
case "qrp": case "qrp":
//todo if (!isset($this->pgin->qrlist) || count($this->pgin->qrlist) == 0) {
$player->sendMessage("QR panel list is empty!");
} else {
if (isset ($args [0])) {
$idToTP = $args[0];
$qrItem = null;
foreach ($this->pgin->qrlist as $li) {
if ($idToTP == $li[0]) {
$qrItem = $li;
}
}
if(isset($qrItem) && !is_null($qrItem) )
{
//get qr code panel coords
$coord = $qrItem[3];
$coord[0] = $coord[0] - 2;
$coord[2] = $coord[2] - 2;
//tp playr
$player->teleport(new Vector3($coord[0], $coord[1], $coord[2]));
$player->sendMessage("You've been teleported nearby QR panel [$idToTP].");
}
else
{
$player->sendMessage("QR panel [$idToTP] not found.");
}
}
else
{
$this->showusage($sender);
}
}
break; break;
default: default:
$this->showusage($sender); $this->showusage($sender);
@@ -124,7 +155,7 @@ class QRcraftCommand
$player->sendMessage("QRcraft usage:"); $player->sendMessage("QRcraft usage:");
$player->sendMessage("/qr - help page"); $player->sendMessage("/qr - help page");
$player->sendMessage("/qrt <url> - test QR text size"); $player->sendMessage("/qrt <url> - test QR text size");
$player->sendMessage("/qrc <url> [Auto|horizontal|vertical] - create qr panel"); $player->sendMessage("/qrc <url> [Auto|horizontal|vertical] - create QR panel");
$player->sendMessage("/qrl - list QR panels IDs"); $player->sendMessage("/qrl - list QR panels IDs");
$player->sendMessage("/qrd <ID> - detele QR panel by ID"); $player->sendMessage("/qrd <ID> - detele QR panel by ID");
$player->sendMessage("/qrp <ID> - teleport nearby QR panel by ID"); $player->sendMessage("/qrp <ID> - teleport nearby QR panel by ID");
+1 -4
View File
@@ -45,10 +45,7 @@ class QRcraftPlugIn extends PluginBase implements CommandExecutor
public function loadConfiguration() public function loadConfiguration()
{ {
if (!file_exists($this->getDataFolder() . "config.yml")) { $this->saveDefaultConfig();
@mkdir($this->getDataFolder());
file_put_contents($this->getDataFolder() . "config.yml", $this->getResource("config.yml"));
}
} }
public function onDisable() public function onDisable()
+3 -3
View File
@@ -10,7 +10,7 @@
namespace clodyx\qrcraft; namespace clodyx\qrcraft;
include(__DIR__ . "\..\..\clodyx\phpqrcode\phpqrcode.php"); include(__DIR__ . "/../../clodyx/phpqrcode/phpqrcode.php");
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\block\Block as BlockAPI; use pocketmine\block\Block as BlockAPI;
@@ -201,7 +201,7 @@ class QRhelper
$session["create"] = true; $session["create"] = true;
$player->sendMessage("QR block defined $orientation (" . $size . "x" . $size . ") for '" . $url . "'"); $player->sendMessage("QR panel defined $orientation (" . $size . "x" . $size . ") for '" . $url . "'");
$player->sendMessage("Touch a block to create it!"); $player->sendMessage("Touch a block to create it!");
} }
@@ -245,7 +245,7 @@ class QRhelper
$session["create"] = false; $session["create"] = false;
$session["size"] = 0; $session["size"] = 0;
$player->sendMessage("QR block [$qrID] created OK!"); $player->sendMessage("QR panel [$qrID] created OK!");
} }
} }