mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Added SetDifficultyPacket
This commit is contained in:
parent
1818e64c8e
commit
92143d523c
@ -94,6 +94,7 @@ use pocketmine\network\protocol\Info as ProtocolInfo;
|
|||||||
use pocketmine\network\protocol\LoginStatusPacket;
|
use pocketmine\network\protocol\LoginStatusPacket;
|
||||||
use pocketmine\network\protocol\MessagePacket;
|
use pocketmine\network\protocol\MessagePacket;
|
||||||
use pocketmine\network\protocol\MovePlayerPacket;
|
use pocketmine\network\protocol\MovePlayerPacket;
|
||||||
|
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||||
use pocketmine\network\protocol\SetHealthPacket;
|
use pocketmine\network\protocol\SetHealthPacket;
|
||||||
use pocketmine\network\protocol\SetSpawnPositionPacket;
|
use pocketmine\network\protocol\SetSpawnPositionPacket;
|
||||||
use pocketmine\network\protocol\SetTimePacket;
|
use pocketmine\network\protocol\SetTimePacket;
|
||||||
@ -1447,6 +1448,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->dead = true;
|
$this->dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pk = new SetDifficultyPacket();
|
||||||
|
$pk->difficulty = $this->server->getDifficulty();
|
||||||
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
$this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->id . " at (" . $this->level->getName() . ", " . round($this->x, 4) . ", " . round($this->y, 4) . ", " . round($this->z, 4) . ")");
|
$this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged in with entity id " . $this->id . " at (" . $this->level->getName() . ", " . round($this->x, 4) . ", " . round($this->y, 4) . ", " . round($this->z, 4) . ")");
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
namespace pocketmine\command\defaults;
|
namespace pocketmine\command\defaults;
|
||||||
|
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
@ -55,6 +56,9 @@ class DifficultyCommand extends VanillaCommand{
|
|||||||
|
|
||||||
if($difficulty !== -1){
|
if($difficulty !== -1){
|
||||||
$sender->getServer()->setConfigInt("difficulty", $difficulty);
|
$sender->getServer()->setConfigInt("difficulty", $difficulty);
|
||||||
|
$pk = new SetDifficultyPacket();
|
||||||
|
$pk->difficulty = $sender->getServer()->getDifficulty();
|
||||||
|
Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk);
|
||||||
$sender->sendMessage("Set difficulty to " . $difficulty);
|
$sender->sendMessage("Set difficulty to " . $difficulty);
|
||||||
}else{
|
}else{
|
||||||
$sender->sendMessage("Unknown difficulty");
|
$sender->sendMessage("Unknown difficulty");
|
||||||
|
@ -60,6 +60,7 @@ use pocketmine\network\protocol\RemovePlayerPacket;
|
|||||||
use pocketmine\network\protocol\RespawnPacket;
|
use pocketmine\network\protocol\RespawnPacket;
|
||||||
use pocketmine\network\protocol\RotateHeadPacket;
|
use pocketmine\network\protocol\RotateHeadPacket;
|
||||||
use pocketmine\network\protocol\SendInventoryPacket;
|
use pocketmine\network\protocol\SendInventoryPacket;
|
||||||
|
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||||
use pocketmine\network\protocol\SetEntityDataPacket;
|
use pocketmine\network\protocol\SetEntityDataPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
use pocketmine\network\protocol\SetHealthPacket;
|
use pocketmine\network\protocol\SetHealthPacket;
|
||||||
@ -328,6 +329,7 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
|||||||
$this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class);
|
$this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class);
|
||||||
$this->registerPacket(ProtocolInfo::ENTITY_DATA_PACKET, EntityDataPacket::class);
|
$this->registerPacket(ProtocolInfo::ENTITY_DATA_PACKET, EntityDataPacket::class);
|
||||||
$this->registerPacket(ProtocolInfo::UNLOAD_CHUNK_PACKET, UnloadChunkPacket::class);
|
$this->registerPacket(ProtocolInfo::UNLOAD_CHUNK_PACKET, UnloadChunkPacket::class);
|
||||||
|
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPacket($buffer){
|
private function getPacket($buffer){
|
||||||
|
@ -88,5 +88,6 @@ interface Info{
|
|||||||
//const PLAYER_INPUT_PACKET = 0xb9;
|
//const PLAYER_INPUT_PACKET = 0xb9;
|
||||||
const FULL_CHUNK_DATA_PACKET = 0xba;
|
const FULL_CHUNK_DATA_PACKET = 0xba;
|
||||||
const UNLOAD_CHUNK_PACKET = 0xbb;
|
const UNLOAD_CHUNK_PACKET = 0xbb;
|
||||||
|
const SET_DIFFICULTY_PACKET = 0xbc;
|
||||||
|
|
||||||
}
|
}
|
46
src/pocketmine/network/protocol/SetDifficultyPacket.php
Normal file
46
src/pocketmine/network/protocol/SetDifficultyPacket.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?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\network\protocol;
|
||||||
|
|
||||||
|
#include <rules/DataPacket.h>
|
||||||
|
|
||||||
|
|
||||||
|
class SetDifficultyPacket extends DataPacket{
|
||||||
|
public static $pool = [];
|
||||||
|
public static $next = 0;
|
||||||
|
|
||||||
|
public $difficulty;
|
||||||
|
|
||||||
|
public function pid(){
|
||||||
|
return Info::SET_DIFFICULTY_PACKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decode(){
|
||||||
|
$this->difficulty = $this->getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function encode(){
|
||||||
|
$this->reset();
|
||||||
|
$this->putInt($this->difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user