mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Block placement fixes
This commit is contained in:
parent
a529e7566a
commit
274f8a6113
@ -90,13 +90,13 @@ class BanAPI{
|
|||||||
public function permissionsCheck($data, $event){
|
public function permissionsCheck($data, $event){
|
||||||
switch($event){
|
switch($event){
|
||||||
case "player.flying"://OPs can fly around the server.
|
case "player.flying"://OPs can fly around the server.
|
||||||
if($this->isOp($data->iusername)){
|
if($this->isOp($data->getUsername())){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "player.block.break":
|
case "player.block.break":
|
||||||
case "player.block.place"://Spawn protection detection. Allows OPs to place/break blocks in the spawn area.
|
case "player.block.place"://Spawn protection detection. Allows OPs to place/break blocks in the spawn area.
|
||||||
if(!$this->isOp($data["player"]->iusername)){
|
if(!$this->isOp($data["player"]->getUsername())){
|
||||||
$t = new Vector2($data["target"]->x, $data["target"]->z);
|
$t = new Vector2($data["target"]->x, $data["target"]->z);
|
||||||
$s = new Vector2($this->server->spawn->x, $this->server->spawn->z);
|
$s = new Vector2($this->server->spawn->x, $this->server->spawn->z);
|
||||||
if($t->distance($s) <= $this->server->api->getProperty("spawn-protection") and $this->server->api->dhandle($event.".spawn", $data) !== true){
|
if($t->distance($s) <= $this->server->api->getProperty("spawn-protection") and $this->server->api->dhandle($event.".spawn", $data) !== true){
|
||||||
@ -110,7 +110,7 @@ class BanAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($data["issuer"] instanceof Player){
|
if($data["issuer"] instanceof Player){
|
||||||
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->iusername)){
|
if($this->server->api->handle("console.check", $data) === true or $this->isOp($data["issuer"]->getUsername())){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
|
}elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
|
||||||
@ -154,10 +154,10 @@ class BanAPI{
|
|||||||
$output .= $user." is now op\n";
|
$output .= $user." is now op\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->ops->set($player->iusername);
|
$this->ops->set(strtolower($player->getUsername()));
|
||||||
$this->ops->save();
|
$this->ops->save();
|
||||||
$output .= $player->iusername." is now op\n";
|
$output .= $player->getUsername()." is now op\n";
|
||||||
$this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
|
$this->server->api->chat->sendTo(false, "You are now op.", $player->getUsername());
|
||||||
break;
|
break;
|
||||||
case "deop":
|
case "deop":
|
||||||
$user = strtolower($params[0]);
|
$user = strtolower($params[0]);
|
||||||
@ -168,10 +168,10 @@ class BanAPI{
|
|||||||
$output .= $user." is no longer op\n";
|
$output .= $user." is no longer op\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->ops->remove($player->iusername);
|
$this->ops->remove(strtolower($player->getUsername()));
|
||||||
$this->ops->save();
|
$this->ops->save();
|
||||||
$output .= $player->iusername." is no longer op\n";
|
$output .= $player->getUsername()." is no longer op\n";
|
||||||
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
|
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->getUsername());
|
||||||
break;
|
break;
|
||||||
case "kick":
|
case "kick":
|
||||||
if(!isset($params[0])){
|
if(!isset($params[0])){
|
||||||
|
@ -377,7 +377,11 @@ class BlockAPI{
|
|||||||
|
|
||||||
$target = $player->level->getBlock($vector);
|
$target = $player->level->getBlock($vector);
|
||||||
$block = $target->getSide($face);
|
$block = $target->getSide($face);
|
||||||
$item = $player->getSlot($player->slot);
|
if(($player->getGamemode() & 0x01) === 0){
|
||||||
|
$item = $player->getSlot($player->slot);
|
||||||
|
}else{
|
||||||
|
$item = BlockAPI::getItem(BlockAPI::$creative[$player->slot][0], BlockAPI::$creative[$player->slot][1], 1);
|
||||||
|
}
|
||||||
|
|
||||||
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE
|
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE
|
||||||
if($this->server->api->dhandle("player.block.place.bypass", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){
|
if($this->server->api->dhandle("player.block.place.bypass", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){
|
||||||
@ -460,7 +464,7 @@ class BlockAPI{
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($player->gamemode & 0x01) === 0x00){
|
if(($player->getGamemode() & 0x01) === 0){
|
||||||
$item->setCount($item->getCount() - 1);
|
$item->setCount($item->getCount() - 1);
|
||||||
if($item->getCount() <= 0){
|
if($item->getCount() <= 0){
|
||||||
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0));
|
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0));
|
||||||
|
@ -73,6 +73,7 @@ class Player extends PlayerEntity{
|
|||||||
private $packetLoss = 0;
|
private $packetLoss = 0;
|
||||||
private $lastChunk = false;
|
private $lastChunk = false;
|
||||||
private $chunkScheduled = 0;
|
private $chunkScheduled = 0;
|
||||||
|
private $inAction = false;
|
||||||
public $lastCorrect;
|
public $lastCorrect;
|
||||||
private $bigCnt;
|
private $bigCnt;
|
||||||
private $packetStats;
|
private $packetStats;
|
||||||
@ -1059,23 +1060,9 @@ class Player extends PlayerEntity{
|
|||||||
|
|
||||||
$inv =& $this->inventory;
|
$inv =& $this->inventory;
|
||||||
if(($this->gamemode & 0x01) === ($gm & 0x01)){
|
if(($this->gamemode & 0x01) === ($gm & 0x01)){
|
||||||
if(($gm & 0x01) === 0x01 and ($gm & 0x02) === 0x02){
|
|
||||||
$inv = array();
|
|
||||||
foreach(BlockAPI::$creative as $item){
|
|
||||||
$inv[] = BlockAPI::getItem(DANDELION, 0, 1);
|
|
||||||
}
|
|
||||||
}elseif(($gm & 0x01) === 0x01){
|
|
||||||
$inv = array();
|
|
||||||
foreach(BlockAPI::$creative as $item){
|
|
||||||
$inv[] = BlockAPI::getItem($item[0], $item[1], 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->gamemode = $gm;
|
$this->gamemode = $gm;
|
||||||
$this->sendChat("Your gamemode has been changed to ".$this->getGamemode().".\n");
|
$this->sendChat("Your gamemode has been changed to ".$this->getGamemode().".\n");
|
||||||
}else{
|
}else{
|
||||||
foreach($this->inventory as $slot => $item){
|
|
||||||
$inv[$slot] = BlockAPI::getItem(AIR, 0, 0);
|
|
||||||
}
|
|
||||||
$this->blocked = true;
|
$this->blocked = true;
|
||||||
$this->gamemode = $gm;
|
$this->gamemode = $gm;
|
||||||
$this->sendChat("Your gamemode has been changed to ".$this->getGamemode().", you've to do a forced reconnect.\n");
|
$this->sendChat("Your gamemode has been changed to ".$this->getGamemode().", you've to do a forced reconnect.\n");
|
||||||
@ -1536,7 +1523,7 @@ class Player extends PlayerEntity{
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
|
case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
|
||||||
if($this->spawned === false){
|
if($this->spawned === false){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1568,6 +1555,7 @@ class Player extends PlayerEntity{
|
|||||||
foreach(BlockAPI::$creative as $i => $d){
|
foreach(BlockAPI::$creative as $i => $d){
|
||||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||||
$packet->slot = $i;
|
$packet->slot = $i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($packet->slot !== false){
|
if($packet->slot !== false){
|
||||||
@ -1590,14 +1578,14 @@ class Player extends PlayerEntity{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//$this->sendInventorySlot($packet->slot);
|
$this->sendInventorySlot($packet->slot);
|
||||||
$this->sendInventory();
|
//$this->sendInventory();
|
||||||
}
|
}
|
||||||
if($this->entity->inAction === true){
|
if($this->inAction === true){
|
||||||
$this->entity->inAction = false;
|
$this->inAction = false;
|
||||||
$this->entity->updateMetadata();
|
//$this->entity->updateMetadata();
|
||||||
}
|
}
|
||||||
break;*/
|
break;
|
||||||
case ProtocolInfo::REQUEST_CHUNK_PACKET:
|
case ProtocolInfo::REQUEST_CHUNK_PACKET:
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::USE_ITEM_PACKET:
|
case ProtocolInfo::USE_ITEM_PACKET:
|
||||||
@ -1651,6 +1639,9 @@ class Player extends PlayerEntity{
|
|||||||
|
|
||||||
if($this->blocked === true or $blockVector->distance($this) > 10){
|
if($this->blocked === true or $blockVector->distance($this) > 10){
|
||||||
|
|
||||||
|
}elseif(($this->gamemode & 0x01) === 1 and isset(BlockAPI::$creative[$this->slot]) and $packet->item === BlockAPI::$creative[$this->slot][0] and $packet->meta === BlockAPI::$creative[$this->slot][1]){
|
||||||
|
$this->server->api->block->playerBlockAction($this, $blockVector, $packet->face, $packet->fx, $packet->fy, $packet->fz);
|
||||||
|
break;
|
||||||
}elseif($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)){
|
}elseif($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)){
|
||||||
$this->sendInventorySlot($this->slot);
|
$this->sendInventorySlot($this->slot);
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user