mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
PHP7 to master
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\block\Air;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\entity\Arrow;
|
||||
@ -76,11 +77,9 @@ use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\inventory\SimpleTransactionGroup;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\ChunkLoader;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Location;
|
||||
use pocketmine\level\Position;
|
||||
@ -90,16 +89,15 @@ use pocketmine\math\Vector2;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Double;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\nbt\tag\Float;
|
||||
use pocketmine\nbt\tag\Int;
|
||||
use pocketmine\nbt\tag\Long;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\nbt\tag\String;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\LongTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\protocol\AnimatePacket;
|
||||
use pocketmine\network\protocol\BatchPacket;
|
||||
@ -110,20 +108,19 @@ use pocketmine\network\protocol\DisconnectPacket;
|
||||
use pocketmine\network\protocol\EntityEventPacket;
|
||||
use pocketmine\network\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\protocol\Info as ProtocolInfo;
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\protocol\RespawnPacket;
|
||||
use pocketmine\network\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\protocol\TextPacket;
|
||||
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\protocol\SetHealthPacket;
|
||||
use pocketmine\network\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\network\protocol\StartGamePacket;
|
||||
use pocketmine\network\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\protocol\TextPacket;
|
||||
use pocketmine\network\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\SourceInterface;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
@ -133,10 +130,9 @@ use pocketmine\tile\Sign;
|
||||
use pocketmine\tile\Spawnable;
|
||||
use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
|
||||
use raklib\Binary;
|
||||
|
||||
|
||||
/**
|
||||
* Main class that handles networking, recovery, and packet sending to the server part
|
||||
*/
|
||||
@ -183,12 +179,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
protected $isCrafting = false;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @var array
|
||||
*/
|
||||
public $loginData = [];
|
||||
|
||||
public $creationTime = 0;
|
||||
|
||||
protected $randomClientId;
|
||||
@ -227,7 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
protected $viewDistance;
|
||||
protected $chunksPerTick;
|
||||
protected $spawnThreshold;
|
||||
protected $spawnThreshold;
|
||||
/** @var null|Position */
|
||||
private $spawnPosition = null;
|
||||
|
||||
@ -296,15 +286,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
public function getFirstPlayed(){
|
||||
return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null;
|
||||
return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null;
|
||||
}
|
||||
|
||||
public function getLastPlayed(){
|
||||
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null;
|
||||
return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
|
||||
}
|
||||
|
||||
public function hasPlayedBefore(){
|
||||
return $this->namedtag instanceof Compound;
|
||||
return $this->namedtag instanceof CompoundTag;
|
||||
}
|
||||
|
||||
public function setAllowFlight($value){
|
||||
@ -503,7 +493,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->interface = $interface;
|
||||
$this->windows = new \SplObjectStorage();
|
||||
$this->perm = new PermissibleBase($this);
|
||||
$this->namedtag = new Compound();
|
||||
$this->namedtag = new CompoundTag();
|
||||
$this->server = Server::getInstance();
|
||||
$this->lastBreak = PHP_INT_MAX;
|
||||
$this->ip = $ip;
|
||||
@ -511,7 +501,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->clientID = $clientID;
|
||||
$this->loaderId = Level::generateChunkLoaderId($this);
|
||||
$this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4);
|
||||
$this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56);
|
||||
$this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56);
|
||||
$this->spawnPosition = null;
|
||||
$this->gamemode = $this->server->getGamemode();
|
||||
$this->setLevel($this->server->getDefaultLevel());
|
||||
@ -565,9 +555,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setDisplayName($name){
|
||||
$this->displayName = $name;
|
||||
if($this->spawned){
|
||||
@ -889,11 +879,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isset($this->batchedPackets[$packet->getChannel()])){
|
||||
$this->batchedPackets[$packet->getChannel()] = [];
|
||||
}
|
||||
|
||||
$this->batchedPackets[$packet->getChannel()][] = clone $packet;
|
||||
$this->batchedPackets[] = clone $packet;
|
||||
$timings->stopTiming();
|
||||
return true;
|
||||
}
|
||||
@ -1100,7 +1086,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->spawnToAll();
|
||||
}
|
||||
|
||||
$this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode);
|
||||
$this->namedtag->playerGameType = new IntTag("playerGameType", $this->gamemode);
|
||||
|
||||
$pk = new SetPlayerGameTypePacket();
|
||||
$pk->gamemode = $this->gamemode & 0x01;
|
||||
@ -1216,20 +1202,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function addEntityMotion($entityId, $x, $y, $z){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function addEntityMovement($entityId, $x, $y, $z, $yaw, $pitch, $headYaw = null){
|
||||
|
||||
}
|
||||
|
||||
public function setDataProperty($id, $type, $value){
|
||||
if(parent::setDataProperty($id, $type, $value)){
|
||||
$this->sendData($this, [$id => $this->dataProperties[$id]]);
|
||||
@ -1554,9 +1526,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
if(count($this->batchedPackets) > 0){
|
||||
foreach($this->batchedPackets as $channel => $list){
|
||||
$this->server->batchPackets([$this], $list, false, $channel);
|
||||
}
|
||||
$this->server->batchPackets([$this], $this->batchedPackets, false);
|
||||
$this->batchedPackets = [];
|
||||
}
|
||||
|
||||
@ -1628,14 +1598,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$nbt = $this->server->getOfflinePlayerData($this->username);
|
||||
if(!isset($nbt->NameTag)){
|
||||
$nbt->NameTag = new String("NameTag", $this->username);
|
||||
$nbt->NameTag = new StringTag("NameTag", $this->username);
|
||||
}else{
|
||||
$nbt["NameTag"] = $this->username;
|
||||
}
|
||||
$this->gamemode = $nbt["playerGameType"] & 0x03;
|
||||
if($this->server->getForceGamemode()){
|
||||
$this->gamemode = $this->server->getGamemode();
|
||||
$nbt->playerGameType = new Int("playerGameType", $this->gamemode);
|
||||
$nbt->playerGameType = new IntTag("playerGameType", $this->gamemode);
|
||||
}
|
||||
|
||||
$this->allowFlight = $this->isCreative();
|
||||
@ -1651,7 +1621,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->setLevel($level);
|
||||
}
|
||||
|
||||
if(!($nbt instanceof Compound)){
|
||||
if(!($nbt instanceof CompoundTag)){
|
||||
$this->close($this->getLeaveMessage(), "Invalid data");
|
||||
|
||||
return;
|
||||
@ -1664,7 +1634,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
|
||||
}
|
||||
|
||||
$nbt->lastPlayed = new Long("lastPlayed", floor(microtime(true) * 1000));
|
||||
$nbt->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
|
||||
if($this->server->getAutoSave()){
|
||||
$this->server->saveOfflinePlayerData($this->username, $nbt, true);
|
||||
}
|
||||
@ -1936,13 +1906,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($packet->slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($packet->slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}elseif($item === null or $slot === -1 or !$item->deepEquals($packet->item)){ // packet error or not implemented
|
||||
$this->inventory->sendContents($this);
|
||||
@ -1952,13 +1922,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->inventory->setItem($packet->selectedSlot, $item);
|
||||
$this->inventory->setHeldItemSlot($packet->selectedSlot);
|
||||
}else{
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
@ -2031,20 +2001,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
if($item->getId() === Item::SNOWBALL){
|
||||
$nbt = new Compound("", [
|
||||
"Pos" => new Enum("Pos", [
|
||||
new Double("", $this->x),
|
||||
new Double("", $this->y + $this->getEyeHeight()),
|
||||
new Double("", $this->z)
|
||||
$nbt = new CompoundTag("", [
|
||||
"Pos" => new ListTag("Pos", [
|
||||
new DoubleTag("", $this->x),
|
||||
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
||||
new DoubleTag("", $this->z)
|
||||
]),
|
||||
"Motion" => new Enum("Motion", [
|
||||
new Double("", $aimPos->x),
|
||||
new Double("", $aimPos->y),
|
||||
new Double("", $aimPos->z)
|
||||
"Motion" => new ListTag("Motion", [
|
||||
new DoubleTag("", $aimPos->x),
|
||||
new DoubleTag("", $aimPos->y),
|
||||
new DoubleTag("", $aimPos->z)
|
||||
]),
|
||||
"Rotation" => new Enum("Rotation", [
|
||||
new Float("", $this->yaw),
|
||||
new Float("", $this->pitch)
|
||||
"Rotation" => new ListTag("Rotation", [
|
||||
new FloatTag("", $this->yaw),
|
||||
new FloatTag("", $this->pitch)
|
||||
]),
|
||||
]);
|
||||
|
||||
@ -2092,6 +2062,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->inventory->sendHeldItem($this);
|
||||
break;
|
||||
}
|
||||
$block = $target->getSide($packet->face);
|
||||
if($block->getId() === Block::FIRE){
|
||||
$this->level->setBlock($block, new Air());
|
||||
}
|
||||
$this->lastBreak = microtime(true);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_ABORT_BREAK:
|
||||
@ -2099,30 +2073,30 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_RELEASE_ITEM:
|
||||
if($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)){
|
||||
if($this->inventory->getItemInHand()->getId() === Item::BOW) {
|
||||
if($this->inventory->getItemInHand()->getId() === Item::BOW){
|
||||
$bow = $this->inventory->getItemInHand();
|
||||
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) {
|
||||
if($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))){
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$nbt = new Compound("", [
|
||||
"Pos" => new Enum("Pos", [
|
||||
new Double("", $this->x),
|
||||
new Double("", $this->y + $this->getEyeHeight()),
|
||||
new Double("", $this->z)
|
||||
$nbt = new CompoundTag("", [
|
||||
"Pos" => new ListTag("Pos", [
|
||||
new DoubleTag("", $this->x),
|
||||
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
||||
new DoubleTag("", $this->z)
|
||||
]),
|
||||
"Motion" => new Enum("Motion", [
|
||||
new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)),
|
||||
new Double("", -sin($this->pitch / 180 * M_PI)),
|
||||
new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))
|
||||
"Motion" => new ListTag("Motion", [
|
||||
new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)),
|
||||
new DoubleTag("", -sin($this->pitch / 180 * M_PI)),
|
||||
new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))
|
||||
]),
|
||||
"Rotation" => new Enum("Rotation", [
|
||||
new Float("", $this->yaw),
|
||||
new Float("", $this->pitch)
|
||||
"Rotation" => new ListTag("Rotation", [
|
||||
new FloatTag("", $this->yaw),
|
||||
new FloatTag("", $this->pitch)
|
||||
]),
|
||||
"Fire" => new Short("Fire", $this->isOnFire() ? 45 * 60 : 0)
|
||||
"Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0)
|
||||
]);
|
||||
|
||||
$diff = ($this->server->getTick() - $this->startAction);
|
||||
@ -2130,35 +2104,35 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$f = min((($p ** 2) + $p * 2) / 3, 1) * 2;
|
||||
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
|
||||
|
||||
if ($f < 0.1 or $diff < 5) {
|
||||
if($f < 0.1 or $diff < 5){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
if ($ev->isCancelled()) {
|
||||
if($ev->isCancelled()){
|
||||
$ev->getProjectile()->kill();
|
||||
$this->inventory->sendContents($this);
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
|
||||
if($this->isSurvival()){
|
||||
$this->inventory->removeItem(Item::get(Item::ARROW, 0, 1));
|
||||
$bow->setDamage($bow->getDamage() + 1);
|
||||
if ($bow->getDamage() >= 385) {
|
||||
if($bow->getDamage() >= 385){
|
||||
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
|
||||
} else {
|
||||
}else{
|
||||
$this->inventory->setItemInHand($bow);
|
||||
}
|
||||
}
|
||||
if ($ev->getProjectile() instanceof Projectile) {
|
||||
if($ev->getProjectile() instanceof Projectile){
|
||||
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
|
||||
if ($projectileEv->isCancelled()) {
|
||||
if($projectileEv->isCancelled()){
|
||||
$ev->getProjectile()->kill();
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->spawnToAll();
|
||||
$this->level->addSound(new LaunchSound($this), $this->getViewers());
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->spawnToAll();
|
||||
}
|
||||
}
|
||||
@ -2176,7 +2150,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->dataPacket($pk);
|
||||
Server::broadcastPacket($this->getViewers(), $pk);
|
||||
|
||||
if ($this->isSurvival()) {
|
||||
if($this->isSurvival()){
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
--$slot->count;
|
||||
$this->inventory->setItemInHand($slot);
|
||||
@ -2304,7 +2278,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
|
||||
$this->inventory->sendHeldItem($this);
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
if($tile instanceof Spawnable){
|
||||
$tile->spawnTo($this);
|
||||
@ -2511,7 +2485,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if(is_array($amount)){
|
||||
$amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
|
||||
}
|
||||
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
|
||||
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
|
||||
$this->heal($ev->getAmount(), $ev);
|
||||
|
||||
--$slot->count;
|
||||
@ -2675,7 +2649,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$result = $packet->output[0];
|
||||
|
||||
if(!$canCraft or !$recipe->getResult()->deepEquals($result)){
|
||||
$this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": expected " . $recipe->getResult() . ", got ". $result .", using: " . implode(", ", $ingredients));
|
||||
$this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": expected " . $recipe->getResult() . ", got " . $result . ", using: " . implode(", ", $ingredients));
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
@ -2685,7 +2659,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
foreach($ingredients as $ingredient){
|
||||
$slot = -1;
|
||||
foreach($this->inventory->getContents() as $index => $i){
|
||||
if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $i->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){
|
||||
if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $ingredient->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){
|
||||
$slot = $index;
|
||||
$used[$index]++;
|
||||
break;
|
||||
@ -2699,7 +2673,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
if(!$canCraft){
|
||||
$this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": client does not have enough items, using: " . implode(", ", $ingredients));
|
||||
$this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": client does not have enough items, using: " . implode(", ", $ingredients));
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
@ -2913,11 +2887,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage()));
|
||||
if(!$ev->isCancelled()){
|
||||
if($isAdmin){
|
||||
if(!$this->isBanned()) {
|
||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
||||
}else{
|
||||
$message = $reason;
|
||||
}
|
||||
if(!$this->isBanned()){
|
||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
||||
}else{
|
||||
$message = $reason;
|
||||
}
|
||||
}else{
|
||||
if($reason === ""){
|
||||
$message = "disconnectionScreen.noReason";
|
||||
@ -2940,11 +2914,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
*/
|
||||
public function sendMessage($message){
|
||||
if($message instanceof TextContainer){
|
||||
if ($message instanceof TranslationContainer) {
|
||||
$this->sendTranslation($message->getText(), $message->getParameters());
|
||||
return;
|
||||
}
|
||||
$message = $message->getText();
|
||||
if($message instanceof TranslationContainer){
|
||||
$this->sendTranslation($message->getText(), $message->getParameters());
|
||||
return;
|
||||
}
|
||||
$message = $message->getText();
|
||||
|
||||
}
|
||||
|
||||
@ -2996,7 +2970,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
*
|
||||
* @param string $message Message to be broadcasted
|
||||
* @param string $reason Reason showed in console
|
||||
* @param bool $notify
|
||||
* @param bool $notify
|
||||
*/
|
||||
public final function close($message = "", $reason = "generic reason", $notify = true){
|
||||
|
||||
@ -3092,7 +3066,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
parent::saveNBT();
|
||||
if($this->level instanceof Level){
|
||||
$this->namedtag->Level = new String("Level", $this->level->getName());
|
||||
$this->namedtag->Level = new StringTag("Level", $this->level->getName());
|
||||
if($this->spawnPosition instanceof Position and $this->spawnPosition->getLevel() instanceof Level){
|
||||
$this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName();
|
||||
$this->namedtag["SpawnX"] = (int) $this->spawnPosition->x;
|
||||
@ -3101,13 +3075,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
foreach($this->achievements as $achievement => $status){
|
||||
$this->namedtag->Achievements[$achievement] = new Byte($achievement, $status === true ? 1 : 0);
|
||||
$this->namedtag->Achievements[$achievement] = new ByteTag($achievement, $status === true ? 1 : 0);
|
||||
}
|
||||
|
||||
$this->namedtag["playerGameType"] = $this->gamemode;
|
||||
$this->namedtag["lastPlayed"] = new Long("lastPlayed", floor(microtime(true) * 1000));
|
||||
$this->namedtag["lastPlayed"] = new LongTag("lastPlayed", floor(microtime(true) * 1000));
|
||||
|
||||
if($this->username != "" and $this->namedtag instanceof Compound){
|
||||
if($this->username != "" and $this->namedtag instanceof CompoundTag){
|
||||
$this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async);
|
||||
}
|
||||
}
|
||||
@ -3280,13 +3254,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->isCreative()
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_VOID
|
||||
){
|
||||
$source->setCancelled();
|
||||
}elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){
|
||||
if($this->isCreative()
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_VOID
|
||||
){
|
||||
$source->setCancelled();
|
||||
}elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){
|
||||
$source->setCancelled();
|
||||
}
|
||||
|
||||
@ -3385,11 +3359,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
/**
|
||||
* @param Vector3|Position|Location $pos
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
*/
|
||||
public function teleport(Vector3 $pos, $yaw = null, $pitch = null){
|
||||
if(!$this->isOnline()){
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user