Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
GrabBag-2.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Jul 15, 2015
1 parent 606801c commit 92bb683
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 52 deletions.
13 changes: 10 additions & 3 deletions GrabBag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ that. You are more likely to get a response and help that way.

_NOTE:_

This documentation was last updated for version **2.2.5**.
This documentation was last updated for version **2.2.6**.

Please go to
[github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/GrabBag)
for the most up-to-date documentation.

You can also download this plugin from this [page](https://github.com/alejandroliu/pocketmine-plugins/releases/tag/GrabBag-2.2.5).
You can also download this plugin from this [page](https://github.com/alejandroliu/pocketmine-plugins/releases/tag/GrabBag-2.2.6).

<!-- template-end -->

Expand Down Expand Up @@ -221,6 +221,9 @@ The following commands are available:
- **entities** **nuke** _[all|mobs|others]_
-Clear entities from the server.

Additionally, tiles can be specified by providing the following:

- t(x),(y),(z)[,world]
* **fly**
Toggle flying **ONLY FOR PM1.5**

Expand Down Expand Up @@ -248,7 +251,8 @@ The following commands are available:
obtain an item

This is a shortcut to `/give` that lets player get items for
themselves.
themselves. You can replace **item** with **more** and the
current held item will be duplicated.

* **gift** _[player]_ _&lt;item&gt;_ _[count]_
give an item to a player
Expand Down Expand Up @@ -749,6 +753,8 @@ The following third party libraries are included:

* 2.2.6: Bugfix
* gift command fixing
* ChatMgr crash fixing
* (@SM11) Edit tiles by location (instead of by id)
* 2.2.5:
* Fixed bugs
* CmdSelMgr: configure max
Expand Down Expand Up @@ -880,3 +886,4 @@ The following third party libraries are included:
along with this program. If not, see <http://www.gnu.org/licenses/>.

* * *

2 changes: 1 addition & 1 deletion GrabBag/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load: POSTWORLD

name: GrabBag
description: Collection of miscellaneous commands and listener modules
version: 2.2.5
version: 2.2.6
author: aliuly
website: https://github.com/alejandroliu/pocketmine-plugins/tree/master/GrabBag

Expand Down
1 change: 1 addition & 0 deletions GrabBag/resources/messages/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"Mode"=""
"Money: "=""
"Multiple matches, showing first match!"=""
"Must be holding something"=""
"Must specified a player and a command"=""
"Must specify a player to slay"=""
"Mutes: %1%"=""
Expand Down
1 change: 1 addition & 0 deletions GrabBag/resources/messages/spa.ini
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"Mode"="Modo"
"Money: "="Dinero: "
"Multiple matches, showing first match!"="Varias opciones, mostrando solo la primera!"
"Must be holding something"="Tiene que tener algo en la mano"
"Must specified a player and a command"="Debe proporcionar un jugador y un comando"
"Must specify a player to slay"="Debe de proporcionar un jugador para eliminar"
"Mutes: %1%"="Mudos: %1%"
Expand Down
2 changes: 1 addition & 1 deletion GrabBag/src/aliuly/grabbag/CmdChatMgr.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function onCommand(CommandSender $sender,Command $cmd,$label, array $args
case "nick":
if (!MPMU::inGame($sender)) return true;
if (count($args) == 0) {
$sender->sendName(mc::_("Current nick is: %1%",$sender->getDisplayName()));
$sender->sendMessage(mc::_("Current nick is: %1%",$sender->getDisplayName()));
return true;
}
if (count($args) !== 1) return false;
Expand Down
22 changes: 22 additions & 0 deletions GrabBag/src/aliuly/grabbag/CmdEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
** - **entities** **nuke** _[all|mobs|others]_
** -Clear entities from the server.
**
** Additionally, tiles can be specified by providing the following:
**
** - t(x),(y),(z)[,world]
**/
namespace aliuly\grabbag;

use pocketmine\command\CommandExecutor;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\math\Vector3;

use pocketmine\Player;
use pocketmine\entity\Living;
Expand Down Expand Up @@ -131,6 +135,24 @@ private function getTile($id) {
if (strtolower(substr($id,0,1)) == "t") {
$id = substr($id,1);
}
if (preg_match('/^(\d+),(\d+),(\d+),(\S+)$/',$id,$mv)) {
$l = $this->owner->getServer()->getLevelByName($mv[4]);
if ($l === null) return null;
$mv = new Vector3($mv[1],$mv[2],$mv[3]);
return $l->getTile($mv);
}
if (preg_match('/^(\d+),(\d+),(\d+)$/',$id,$mv)) {
$l = $this->owner->getServer()->getDefaultLevel();
if ($l === null) return null;
$mv = new Vector3($mv[1],$mv[2],$mv[3]);
$e = $l->getTile($mv);
if ($e !== null) return $e;
foreach($this->owner->getServer()->getLevels() as $l) {
$e = $l->getTile($mv);
if ($e !== null) return $e;
}
return null;
}
if (!is_numeric($id)) return null;
$id = intval($id);
foreach($this->owner->getServer()->getLevels() as $l) {
Expand Down
94 changes: 47 additions & 47 deletions GrabBag/src/aliuly/grabbag/CmdGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
** usage: **get** _<item>_ _[count]_
**
** This is a shortcut to `/give` that lets player get items for
** themselves.
** themselves. You can replace **item** with **more** and the
** current held item will be duplicated.
**
** * gift : give an item to a player
** usage: **gift** _[player]_ _<item>_ _[count]_
Expand All @@ -31,8 +32,11 @@

class CmdGet extends BasicCli implements CommandExecutor {
// Override the MaxStacks counter...
static $stacks = [ Item::MINECART => 1, Item::BOOK => 1, Item::COMPASS => 1,
Item::CLOCK => 1 ];
static $stacks = [
Item::MINECART => 1, Item::BOOK => 1, Item::COMPASS => 1,
Item::CLOCK => 1, Item::SPAWN_EGG => 1, Item::FURNACE => 1,
Item::CHEST => 16, Item::TORCH => 16, Item::NETHER_REACTOR => 16,
];

public function __construct($owner) {
parent::__construct($owner);
Expand All @@ -46,69 +50,65 @@ public function __construct($owner) {
"permission" => "gb.cmd.get"]);

}
public function cmdGift(CommandSender $c,$args) {
if (($receiver = $this->owner->getPlayer($args[0])) == null) {
if (MPMU::inGame($c)) return true;
$receiver = $c;

public function onCommand(CommandSender $sender,Command $cmd,$label, array $args) {
if (!isset($args[0])) return false;
if ($cmd->getName() == "gift") {
if (($receiver = $this->owner->getServer()->getPlayer($args[0])) == null) {
if (!MPMU::inGame($sender)) return true;
$receiver= $sender;
} else {
array_shift($args);
}
} else {
array_shift($args);
if (!MPMU::inGame($sender)) return true;
$receiver = $sender;
}
if (!count($args)) return false;

if ($receiver->isCreative()) {
$sender->sendMessage(mc::_("%1% is in creative mode", $receiver->getDisplayName()));
if ($receiver === $sender)
$receiver->sendMessage(mc::_("You are in creative mode"));
else
$sender->sendMessage(mc::_("%1% is in creative mode", $receiver->getDisplayName()));
return true;
}
$item = Item::fromString($args[0]);
if ($item->getId() == 0) {
$sender->sendMessage(TextFormat::RED.
mc::_("There is no item called %1%",$args[0]));
return true;

if (count($args) > 1 && is_numeric($args[count($args)-1])) {
$amt = (int)array_pop($args);
} else {
$amt = -1;
}
if (isset($args[1])) {
$item->setCount((int)$args[1]);

$args = strtolower(implode("_",$args));
if ($args == "more") {
$item = clone $receiver->getInventory()->getItemInHand();
if ($item->getId() == 0) {
$sender->sendMessage(TextFormat::RED.
mc::_("Must be holding something"));
return true;
}
} else {
if (isset(self::$stacks[$item->getId()])) {
$item->setCount(self::$stacks[$item->getId()]);
} else {
$item->setCount($item->getMaxStackSize());
$item = Item::fromString($args);
if ($item->getId() == 0) {
$sender->sendMessage(TextFormat::RED.
mc::_("There is no item called %1%",$args));
return true;
}
}
$receiver->getInventory()->addItem(clone $item);
$this->owner->getServer()->broadcastMessage(
mc::_("%1% got %2% of %3% (%4%:%5%)",
$receiver->getDisplayName(),
$item->getCount(),ItemName::str($item),
$item->getId(),$item->getDamage()));
return true;
}
public function onCommand(CommandSender $sender,Command $cmd,$label, array $args) {
if (!isset($args[0])) return false;
if ($cmd->getName() == "gift") return cmdGift($sender,$args);
if ($cmd->getName() != "get") return false;
if ($sender->isCreative()) {
$sender->sendMessage(mc::_("You are in creative mode"));
return true;
}
$item = Item::fromString($args[0]);
if ($item->getId() == 0) {
$sender->sendMessage(TextFormat::RED.
mc::_("There is no item called %1%",$args[0]));
return true;
}

if (isset($args[1])) {
$item->setCount((int)$args[1]);
if ($amt != -1) {
$item->setCount($amt);
} else {
if (isset(self::$stacks[$item->getId()])) {
$item->setCount(self::$stacks[$item->getId()]);
} else {
$item->setCount($item->getMaxStackSize());
}
}
$sender->getInventory()->addItem(clone $item);
$receiver->getInventory()->addItem(clone $item);
$this->owner->getServer()->broadcastMessage(
mc::_("%1% got %2% of %3% (%4%:%5%)",
$sender->getDisplayName(),
$receiver->getDisplayName(),
$item->getCount(),ItemName::str($item),
$item->getId(),$item->getDamage()));
return true;
Expand Down

0 comments on commit 92bb683

Please sign in to comment.