mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
Added /me and /say, fixed a bunch of things, chat working
This commit is contained in:
parent
22b5255421
commit
f9a7385b47
@ -275,7 +275,6 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
$this->buffer->data = array();
|
$this->buffer->data = array();
|
||||||
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "handlePacketQueues")), 1);
|
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "handlePacketQueues")), 1);
|
||||||
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "clearQueue")), 20 * 60);
|
$this->tasks[] = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "clearQueue")), 20 * 60);
|
||||||
|
|
||||||
console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2);
|
console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,6 +1029,7 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->username = $packet->username;
|
$this->username = $packet->username;
|
||||||
|
$this->displayName = $this->username;
|
||||||
$this->iusername = strtolower($this->username);
|
$this->iusername = strtolower($this->username);
|
||||||
$this->loginData = array("clientId" => $packet->clientId, "loginData" => $packet->loginData);
|
$this->loginData = array("clientId" => $packet->clientId, "loginData" => $packet->loginData);
|
||||||
|
|
||||||
@ -1075,6 +1075,8 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$this->server->getPluginManager()->subscribeToPermission(Player::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
|
||||||
|
$this->server->getPluginManager()->subscribeToPermission(Player::BROADCAST_CHANNEL_USERS, $this);
|
||||||
$this->loggedIn = true;
|
$this->loggedIn = true;
|
||||||
|
|
||||||
$u = Player::get($this->iusername, false, true);
|
$u = Player::get($this->iusername, false, true);
|
||||||
@ -2072,6 +2074,8 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
|
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
|
||||||
Player::broadcastMessage($ev->getQuitMessage());
|
Player::broadcastMessage($ev->getQuitMessage());
|
||||||
}
|
}
|
||||||
|
$this->server->getPluginManager()->unsubscribeFromPermission(Player::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
|
||||||
|
$this->server->getPluginManager()->unsubscribeFromPermission(Player::BROADCAST_CHANNEL_USERS, $this);
|
||||||
$this->spawned = false;
|
$this->spawned = false;
|
||||||
console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason);
|
console("[INFO] " . TextFormat::AQUA . $this->username . TextFormat::RESET . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . $reason);
|
||||||
$this->windows = array();
|
$this->windows = array();
|
||||||
@ -2145,7 +2149,7 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
public static function broadcastMessage($message){
|
public static function broadcastMessage($message){
|
||||||
self::groupChat($message, self::getAll());
|
self::groupChat($message, Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Player::BROADCAST_CHANNEL_USERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2319,9 +2323,11 @@ class Player extends RealHuman implements CommandSender{
|
|||||||
*/
|
*/
|
||||||
public static function groupChat($message, array $players){
|
public static function groupChat($message, array $players){
|
||||||
foreach($players as $p){
|
foreach($players as $p){
|
||||||
|
if($p instanceof CommandSender){
|
||||||
$p->sendMessage($message);
|
$p->sendMessage($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the username
|
* Gets the username
|
||||||
|
@ -26,9 +26,11 @@ use PocketMine\Command\Defaults\BanIpCommand;
|
|||||||
use PocketMine\Command\Defaults\BanListCommand;
|
use PocketMine\Command\Defaults\BanListCommand;
|
||||||
use PocketMine\Command\Defaults\DefaultGamemodeCommand;
|
use PocketMine\Command\Defaults\DefaultGamemodeCommand;
|
||||||
use PocketMine\Command\Defaults\HelpCommand;
|
use PocketMine\Command\Defaults\HelpCommand;
|
||||||
|
use PocketMine\Command\Defaults\MeCommand;
|
||||||
use PocketMine\Command\Defaults\PardonCommand;
|
use PocketMine\Command\Defaults\PardonCommand;
|
||||||
use PocketMine\Command\Defaults\PardonIpCommand;
|
use PocketMine\Command\Defaults\PardonIpCommand;
|
||||||
use PocketMine\Command\Defaults\PluginsCommand;
|
use PocketMine\Command\Defaults\PluginsCommand;
|
||||||
|
use PocketMine\Command\Defaults\SayCommand;
|
||||||
use PocketMine\Command\Defaults\SeedCommand;
|
use PocketMine\Command\Defaults\SeedCommand;
|
||||||
use PocketMine\Command\Defaults\StopCommand;
|
use PocketMine\Command\Defaults\StopCommand;
|
||||||
use PocketMine\Command\Defaults\TellCommand;
|
use PocketMine\Command\Defaults\TellCommand;
|
||||||
@ -52,7 +54,6 @@ class SimpleCommandMap implements CommandMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function setDefaultCommands(){
|
private function setDefaultCommands(){
|
||||||
//TODO
|
|
||||||
$this->register("pocketmine", new VersionCommand("version"));
|
$this->register("pocketmine", new VersionCommand("version"));
|
||||||
$this->register("pocketmine", new PluginsCommand("plugins"));
|
$this->register("pocketmine", new PluginsCommand("plugins"));
|
||||||
$this->register("pocketmine", new SeedCommand("seed"));
|
$this->register("pocketmine", new SeedCommand("seed"));
|
||||||
@ -65,6 +66,8 @@ class SimpleCommandMap implements CommandMap{
|
|||||||
$this->register("pocketmine", new BanListCommand("banlist"));
|
$this->register("pocketmine", new BanListCommand("banlist"));
|
||||||
$this->register("pocketmine", new PardonCommand("pardon"));
|
$this->register("pocketmine", new PardonCommand("pardon"));
|
||||||
$this->register("pocketmine", new PardonIpCommand("pardon-ip"));
|
$this->register("pocketmine", new PardonIpCommand("pardon-ip"));
|
||||||
|
$this->register("pocketmine", new SayCommand("say"));
|
||||||
|
$this->register("pocketmine", new MeCommand("me"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
61
src/PocketMine/command/defaults/MeCommand.php
Normal file
61
src/PocketMine/command/defaults/MeCommand.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?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\Player;
|
||||||
|
use PocketMine\Utils\TextFormat;
|
||||||
|
|
||||||
|
class MeCommand extends VanillaCommand{
|
||||||
|
|
||||||
|
public function __construct($name){
|
||||||
|
parent::__construct(
|
||||||
|
$name,
|
||||||
|
"Performs the specified action in chat",
|
||||||
|
"/me <action...>"
|
||||||
|
);
|
||||||
|
$this->setPermission("pocketmine.command.me");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||||
|
if(!$this->testPermission($sender)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($args) === 0){
|
||||||
|
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = "* ";
|
||||||
|
if($sender instanceof Player){
|
||||||
|
$message .= $sender->getDisplayName();
|
||||||
|
}else{
|
||||||
|
$message .= $sender->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Player::broadcastMessage($message . " " . implode(" ", $args));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
64
src/PocketMine/command/defaults/SayCommand.php
Normal file
64
src/PocketMine/command/defaults/SayCommand.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\Command\ConsoleCommandSender;
|
||||||
|
use PocketMine\Player;
|
||||||
|
use PocketMine\Utils\TextFormat;
|
||||||
|
|
||||||
|
class SayCommand extends VanillaCommand{
|
||||||
|
|
||||||
|
public function __construct($name){
|
||||||
|
parent::__construct(
|
||||||
|
$name,
|
||||||
|
"Broadcasts the given message as the sender",
|
||||||
|
"/say <message...>"
|
||||||
|
);
|
||||||
|
$this->setPermission("pocketmine.command.seed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||||
|
if(!$this->testPermission($sender)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($args) === 0){
|
||||||
|
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = TextFormat::LIGHT_PURPLE . "[";
|
||||||
|
if($sender instanceof ConsoleCommandSender){
|
||||||
|
$message .= "Server";
|
||||||
|
}elseif($sender instanceof Player){
|
||||||
|
$message .= $sender->getDisplayName();
|
||||||
|
}else{
|
||||||
|
$message .= $sender->getName();
|
||||||
|
}
|
||||||
|
$message .= TextFormat::LIGHT_PURPLE . "] " . implode(" ", $args);
|
||||||
|
Player::broadcastMessage($message);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ namespace PocketMine\Event\Player;
|
|||||||
|
|
||||||
use PocketMine\Event\Cancellable;
|
use PocketMine\Event\Cancellable;
|
||||||
use PocketMine\Player;
|
use PocketMine\Player;
|
||||||
|
use PocketMine\Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player chats something
|
* Called when a player chats something
|
||||||
@ -46,7 +47,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
|||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
$this->format = $format;
|
$this->format = $format;
|
||||||
if($recipients === null){
|
if($recipients === null){
|
||||||
$this->recipients = Player::getAll();
|
$this->recipients = Server::getInstance()->getPluginManager()->getPermissionSubscriptions(Player::BROADCAST_CHANNEL_USERS);
|
||||||
}else{
|
}else{
|
||||||
$this->recipients = $recipients;
|
$this->recipients = $recipients;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,8 @@ class Level{
|
|||||||
/** @var Level */
|
/** @var Level */
|
||||||
public static $default = null;
|
public static $default = null;
|
||||||
|
|
||||||
|
public static $saveEnabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Player[]
|
* @var Player[]
|
||||||
*/
|
*/
|
||||||
@ -533,7 +535,7 @@ class Level{
|
|||||||
unset($this->usedChunks[$i]);
|
unset($this->usedChunks[$i]);
|
||||||
LevelFormat::getXZ($i, $X, $Z);
|
LevelFormat::getXZ($i, $X, $Z);
|
||||||
if(!$this->isSpawnChunk($X, $Z)){
|
if(!$this->isSpawnChunk($X, $Z)){
|
||||||
$this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
$this->level->unloadChunk($X, $Z, self::$saveEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -570,7 +572,7 @@ class Level{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//TODO: save enabled/disabled
|
//TODO: save enabled/disabled
|
||||||
/*if($this->server->saveEnabled === false and $force === false){
|
/*if(self::$saveEnabled === false and $force === false){
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@ -1070,7 +1072,7 @@ class Level{
|
|||||||
unset($this->chunkTiles[$index]);
|
unset($this->chunkTiles[$index]);
|
||||||
Cache::remove("world:{$this->name}:$X:$Z");
|
Cache::remove("world:{$this->name}:$X:$Z");
|
||||||
|
|
||||||
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
return $this->level->unloadChunk($X, $Z, self::$saveEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user