Added /tell

This commit is contained in:
Shoghi Cervantes 2014-03-28 03:40:12 +01:00
parent 2f20d95e5d
commit a7269c7900
7 changed files with 80 additions and 0 deletions

View File

@ -33,6 +33,7 @@ use PocketMine\Command\PluginCommand;
use PocketMine\Command\SimpleCommandMap;
use PocketMine\Entity\Entity;
use PocketMine\Event\Event;
use PocketMine\Event\HandlerList;
use PocketMine\Event\Server\PacketReceiveEvent;
use PocketMine\Event\Server\PacketSendEvent;
use PocketMine\Item\Item;
@ -672,6 +673,7 @@ class Server{
$level->unload(true);
}
HandlerList::unregisterAll();
$this->scheduler->cancelAllTasks();
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);

View File

@ -23,6 +23,7 @@ namespace PocketMine\Command;
use PocketMine\Command\Defaults\PluginsCommand;
use PocketMine\Command\Defaults\StopCommand;
use PocketMine\Command\Defaults\TellCommand;
use PocketMine\Command\Defaults\VanillaCommand;
use PocketMine\Command\Defaults\VersionCommand;
use PocketMine\Command\Defaults\SeedCommand;
@ -53,6 +54,7 @@ class SimpleCommandMap implements CommandMap{
$this->register("pocketmine", new SeedCommand("seed"));
$this->register("pocketmine", new HelpCommand("help"));
$this->register("pocketmine", new StopCommand("stop"));
$this->register("pocketmine", new TellCommand("tell"));
}

View File

@ -0,0 +1,64 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace PocketMine\Command\Defaults;
use PocketMine\Command\CommandSender;
use PocketMine\Utils\TextFormat;
use PocketMine\Player;
use PocketMine\Level\Level;
class TellCommand extends VanillaCommand{
public function __construct($name){
parent::__construct(
$name,
"Sends a private message to the given player",
"/tell <player> <message>",
["w", "msg"]
);
$this->setPermission("pocketmine.command.tell");
}
public function execute(CommandSender $sender, $currentAlias, array $args){
if(!$this->testPermission($sender)){
return true;
}
if(count($args) < 2){
$sender->sendMessage(TextFormat::RED . "Usage: ".$this->usageMessage);
return false;
}
$name = strtolower(array_shift($args));
$player = Player::get($name, true, false);
if($player instanceof Player){
$sender->sendMessage("[me -> ".$player->getName()."] ".implode($args));
$player->sendMessage("[".$sender->getName()." -> me] ".implode($args));
}else{
$sender->sendMessage("There's no player by that name online.");
}
return true;
}
}

View File

@ -19,6 +19,9 @@
*
*/
/**
* Event related classes
*/
namespace PocketMine\Event;
abstract class Event{

View File

@ -19,6 +19,9 @@
*
*/
/**
* Permission related classes
*/
namespace PocketMine\Permission;
use PocketMine\Server;

View File

@ -19,6 +19,9 @@
*
*/
/**
* Plugin related classes
*/
namespace PocketMine\Plugin;

View File

@ -19,6 +19,9 @@
*
*/
/**
* Task scheduling related classes
*/
namespace PocketMine\Scheduler;
use PocketMine\Plugin\Plugin;