mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 05:34:54 +00:00
Added /tell
This commit is contained in:
parent
2f20d95e5d
commit
a7269c7900
@ -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);
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
|
||||
|
||||
|
64
src/PocketMine/command/defaults/TellCommand.php
Normal file
64
src/PocketMine/command/defaults/TellCommand.php
Normal 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;
|
||||
}
|
||||
}
|
@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Event related classes
|
||||
*/
|
||||
namespace PocketMine\Event;
|
||||
|
||||
abstract class Event{
|
||||
|
@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Permission related classes
|
||||
*/
|
||||
namespace PocketMine\Permission;
|
||||
|
||||
use PocketMine\Server;
|
||||
|
@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin related classes
|
||||
*/
|
||||
namespace PocketMine\Plugin;
|
||||
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Task scheduling related classes
|
||||
*/
|
||||
namespace PocketMine\Scheduler;
|
||||
|
||||
use PocketMine\Plugin\Plugin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user