mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Initial working slash commands on 0.16. TODO: new API
This commit is contained in:
@ -102,6 +102,7 @@ use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\protocol\AnimatePacket;
|
||||
use pocketmine\network\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\protocol\BatchPacket;
|
||||
use pocketmine\network\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\protocol\ContainerClosePacket;
|
||||
@ -1686,7 +1687,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->eduMode = 0;
|
||||
$pk->rainLevel = 0; //TODO: implement these properly
|
||||
$pk->lightningLevel = 0;
|
||||
$pk->commandsEnabled = 0;
|
||||
$pk->commandsEnabled = 1;
|
||||
$pk->unknown = "UNKNOWN";
|
||||
$pk->worldName = $this->server->getMotd();
|
||||
$this->dataPacket($pk);
|
||||
@ -1712,6 +1713,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if($this->isOp()){
|
||||
$this->setRemoveFormat(false);
|
||||
}
|
||||
|
||||
$pk = new AvailableCommandsPacket();
|
||||
$data = [];
|
||||
foreach($this->server->getCommandMap()->getCommands() as $command){
|
||||
$data[$command->getName()] = $command->generateJsonData($this);
|
||||
}
|
||||
$pk->commands = json_encode($data);
|
||||
$this->dataPacket($pk);
|
||||
|
||||
if($this->isCreative()){
|
||||
$this->inventory->sendCreativeContents();
|
||||
@ -2483,6 +2492,21 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
|
||||
break;
|
||||
case ProtocolInfo::COMMAND_STEP_PACKET:
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
break;
|
||||
}
|
||||
$this->craftingType = 0;
|
||||
Timings::$playerCommandTimer->startTiming();
|
||||
$commandText = $packet->command;
|
||||
if($packet->args !== null){
|
||||
foreach($packet->args as $arg){ //command ordering will be an issue
|
||||
$commandText .= " " . $arg;
|
||||
}
|
||||
}
|
||||
$this->server->dispatchCommand($this, $commandText);
|
||||
Timings::$playerCommandTimer->stopTiming();
|
||||
break;
|
||||
case ProtocolInfo::TEXT_PACKET:
|
||||
if($this->spawned === false or !$this->isAlive()){
|
||||
break;
|
||||
|
Reference in New Issue
Block a user