Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #81 from KenCir:KenCir/issue80
Browse files Browse the repository at this point in the history
[バグ] 右クリックの行動ができない #80
  • Loading branch information
KenCir authored Aug 8, 2021
2 parents 76bb8d6 + 9030fde commit 054bd0e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/OutiServerPlugin/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Error;
use Exception;
use InvalidArgumentException;
use pocketmine\event\block\{BlockBreakEvent, BlockBurnEvent, SignChangeEvent};
use pocketmine\event\block\{BlockBreakEvent, BlockBurnEvent, BlockPlaceEvent, SignChangeEvent};
use pocketmine\event\Listener;
use pocketmine\event\player\{PlayerChatEvent,
PlayerInteractEvent,
Expand Down Expand Up @@ -111,17 +111,13 @@ public function onInteract(PlayerInteractEvent $event)
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and $this->plugin->db->CheckLandProtection($landid) and !$player->isOp()) {
$event->setCancelled();
}
} elseif(!$player->isOp() and !in_array($levelname, $this->plugin->config->get('Land_Protection_Allow', array()))) {
$event->setCancelled();
}
} elseif ($event->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR) {
if ($landid) {
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and $this->plugin->db->CheckLandProtection($landid) and !$player->isOp()) {
$event->setCancelled();
}
} elseif (!$player->isOp()) $event->setCancelled();
} elseif(!$player->isOp() and !in_array($levelname, $this->plugin->config->get('Land_Protection_Allow', array()))) {
$event->setCancelled();
}
}
} catch (Error | TypeError | Exception | InvalidArgumentException | ArgumentCountError $e) {
$this->plugin->errorHandler->onErrorNotPlayer($e);
Expand Down Expand Up @@ -157,7 +153,7 @@ public function onBreak(BlockBreakEvent $event)
}
}
elseif ($landid) {
if (!$this->plugin->db->CheckLandOwner($landid, $player->getName()) and !$this->plugin->db->checkInvite($landid, $player->getName()) and $this->plugin->db->CheckLandProtection($landid) and !$player->isOp()) {
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and $this->plugin->db->CheckLandProtection($landid) and !$player->isOp()) {
$event->setCancelled();
}
}
Expand Down Expand Up @@ -234,6 +230,7 @@ public function onPlayerKick(PlayerKickEvent $event)
$name = $event->getPlayer()->getName();
$reason = $event->getReason();
$this->plugin->client->sendChatMessage("**$name**がサーバーから追放されました\nReason: $reason\n");
$this->plugin->getServer()->broadcastMessage("{$name}がサーバーから追放されました\nReason: $reason");
} catch (Error | TypeError | Exception | InvalidArgumentException | ArgumentCountError $e) {
$this->plugin->errorHandler->onErrorNotPlayer($e);
}
Expand All @@ -260,4 +257,23 @@ public function onPlayerMove(PlayerMoveEvent $event)
$this->plugin->sound->PlaySound($player);
}
}

public function onBlockPlace(BlockPlaceEvent $event)
{
$player = $event->getPlayer();
$name = $player->getName();
$block = $event->getBlock();
$levelname = $block->getLevel()->getName();
$landid = $this->plugin->db->GetLandId($levelname, (int)$block->x, (int)$block->z);
if(!$player->isOp()) {
if($landid) {
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and !$player->isOp()) {
$event->setCancelled();
}
}
else {
$event->setCancelled();
}
}
}
}

0 comments on commit 054bd0e

Please sign in to comment.