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

Commit

Permalink
[バグ] 右クリックの行動ができない #80
Browse files Browse the repository at this point in the history
fix #80
  • Loading branch information
KenCir committed Aug 8, 2021
1 parent 76bb8d6 commit 07ac5d6
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 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 @@ -109,19 +109,17 @@ public function onInteract(PlayerInteractEvent $event)
}
} elseif ($landid) {
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and $this->plugin->db->CheckLandProtection($landid) and !$player->isOp()) {
echo "OK6" . PHP_EOL;
$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()) {
echo "OK5" . PHP_EOL;
$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,11 +155,13 @@ 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()) {
echo "OK" . PHP_EOL;
$event->setCancelled();
}
}
elseif(!$player->isOp() and !in_array($levelname, $this->plugin->config->get('Land_Protection_Allow', array()))) {
echo "OK2" . PHP_EOL;
$event->setCancelled();
}

Expand Down Expand Up @@ -234,6 +234,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 +261,26 @@ 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()) {
echo "OK7" . PHP_EOL;
if($landid) {
if (!$this->plugin->db->CheckLandOwner($landid, $name) and !$this->plugin->db->checkInvite($landid, $name) and !$player->isOp()) {
$event->setCancelled();
echo "OK3" . PHP_EOL;
}
}
else {
$event->setCancelled();
echo "OK4" . PHP_EOL;
}
}
}
}

0 comments on commit 07ac5d6

Please sign in to comment.