Block placement fixes

This commit is contained in:
Shoghi Cervantes 2014-03-05 01:19:05 +01:00
parent a529e7566a
commit 274f8a6113
3 changed files with 27 additions and 32 deletions

View File

@ -90,13 +90,13 @@ class BanAPI{
public function permissionsCheck($data, $event){
switch($event){
case "player.flying"://OPs can fly around the server.
if($this->isOp($data->iusername)){
if($this->isOp($data->getUsername())){
return true;
}
break;
case "player.block.break":
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);
$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){
@ -110,7 +110,7 @@ class BanAPI{
}
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;
}
}elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
@ -154,10 +154,10 @@ class BanAPI{
$output .= $user." is now op\n";
break;
}
$this->ops->set($player->iusername);
$this->ops->set(strtolower($player->getUsername()));
$this->ops->save();
$output .= $player->iusername." is now op\n";
$this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
$output .= $player->getUsername()." is now op\n";
$this->server->api->chat->sendTo(false, "You are now op.", $player->getUsername());
break;
case "deop":
$user = strtolower($params[0]);
@ -168,10 +168,10 @@ class BanAPI{
$output .= $user." is no longer op\n";
break;
}
$this->ops->remove($player->iusername);
$this->ops->remove(strtolower($player->getUsername()));
$this->ops->save();
$output .= $player->iusername." is no longer op\n";
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
$output .= $player->getUsername()." is no longer op\n";
$this->server->api->chat->sendTo(false, "You are no longer op.", $player->getUsername());
break;
case "kick":
if(!isset($params[0])){

View File

@ -377,7 +377,11 @@ class BlockAPI{
$target = $player->level->getBlock($vector);
$block = $target->getSide($face);
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($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);
if($item->getCount() <= 0){
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0));

View File

@ -73,6 +73,7 @@ class Player extends PlayerEntity{
private $packetLoss = 0;
private $lastChunk = false;
private $chunkScheduled = 0;
private $inAction = false;
public $lastCorrect;
private $bigCnt;
private $packetStats;
@ -1059,23 +1060,9 @@ class Player extends PlayerEntity{
$inv =& $this->inventory;
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->sendChat("Your gamemode has been changed to ".$this->getGamemode().".\n");
}else{
foreach($this->inventory as $slot => $item){
$inv[$slot] = BlockAPI::getItem(AIR, 0, 0);
}
$this->blocked = true;
$this->gamemode = $gm;
$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;
/*case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
case ProtocolInfo::PLAYER_EQUIPMENT_PACKET:
if($this->spawned === false){
break;
}
@ -1568,6 +1555,7 @@ class Player extends PlayerEntity{
foreach(BlockAPI::$creative as $i => $d){
if($d[0] === $packet->item and $d[1] === $packet->meta){
$packet->slot = $i;
break;
}
}
if($packet->slot !== false){
@ -1590,14 +1578,14 @@ class Player extends PlayerEntity{
}
}
}else{
//$this->sendInventorySlot($packet->slot);
$this->sendInventory();
$this->sendInventorySlot($packet->slot);
//$this->sendInventory();
}
if($this->entity->inAction === true){
$this->entity->inAction = false;
$this->entity->updateMetadata();
if($this->inAction === true){
$this->inAction = false;
//$this->entity->updateMetadata();
}
break;*/
break;
case ProtocolInfo::REQUEST_CHUNK_PACKET:
break;
case ProtocolInfo::USE_ITEM_PACKET:
@ -1651,6 +1639,9 @@ class Player extends PlayerEntity{
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)){
$this->sendInventorySlot($this->slot);
}else{