示例#1
1
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $player = $event->getPlayer();
     $level = $player->getLevel();
     $spawn = $level->getSpawnLocation();
     $distance = $spawn->distance($player);
     if ($distance <= $this->cfg->get($level->getName())) {
         if (!$player->hasPermission("customradius.edit")) {
             $event->setCancelled(true);
         }
     }
 }
 public function onPlace(BlockPlaceEvent $event)
 {
     if ($event->getPlayer()->hasPermission("worldprotector.block.place")) {
         $event->setCancelled(false);
     } else {
         $event->setCancelled(true);
     }
 }
 /**
  * @param BlockPlaceEvent $event
  *
  * @priority HIGH
  */
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     // PowerTool
     if ($this->getAPI()->executePowerTool($event->getPlayer(), $event->getItem())) {
         $event->setCancelled(true);
     } elseif ($this->getAPI()->isUnlimitedEnabled($event->getPlayer())) {
         $event->setCancelled(true);
         $pos = new Vector3($event->getBlockReplaced()->getX(), $event->getBlockReplaced()->getY(), $event->getBlockReplaced()->getZ());
         $event->getPlayer()->getLevel()->setBlock($pos, $event->getBlock(), true);
     }
 }
 /** 
  * @param BlockPlaceEvent $event 
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if (!$this->plugin->getStorage()->getShield($event->getPlayer()->getLevel())->isAllowed(Shield::PLACING)) {
         $event->setCancelled(true);
         $event->getPlayer()->sendTip($this->plugin->getConfig()->get("placeNotAllowed"));
     }
 }
示例#5
0
 public function playerBlockPlace(BlockPlaceEvent $event)
 {
     $id = $event->getBlock()->getID();
     $player = $event->getPlayer();
     if ($id == in_array($id, $this->config->get("banned-items"))) {
         if ($player->isOp()) {
             if (!$this->config->get("ops-can-use-items") == true) {
                 $player->sendMessage($this->config->get("msg-item-use"));
                 $event->setCancelled();
             }
         } else {
             $player->sendMessage($this->config->get("msg-item-use"));
             $event->setCancelled();
         }
     }
 }
 public function onPlayerPlaceBlock(BlockPlaceEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $event->setCancelled(true);
         $this->debug->onDebug('BlockPlaceEvent');
     }
 }
示例#7
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $player = $event->getPlayer();
     if (!$player->hasPermission("xperms.build")) {
         $player->sendMessage(TextFormat::RED . $this->plugin->getConfiguration()->getMSGonIBuildPerm());
         $event->setCancelled(true);
     }
 }
 public function onPlace(BlockPlaceEvent $event)
 {
     $username = $event->getPlayer()->getName();
     if (isset($this->PlacePrevent[$username])) {
         $event->setCancelled(true);
         unset($this->PlacePrevent[$username]);
     }
 }
示例#9
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if ($this->plugin->isJailed($event->getPlayer())) {
         $event->getPlayer()->sendMessage("§eYou are not allowed to destroy the jail!\nAdded " . $this->getPlugin()->getConfig()->get("punish-additional-minutes") . " minutes as punishment.");
         $this->getPlugin()->punish($event->getPlayer(), $this->getPlugin()->getConfig()->get("punish-additional-minutes"));
         $event->setCancelled(true);
     }
 }
示例#10
0
 public function onPlace(BlockPlaceEvent $event)
 {
     foreach ($this->tntRun->arenas as $arena) {
         if ($arena->getPlayerManager()->isInArena($event->getPlayer())) {
             $event->setCancelled();
             return;
         }
     }
 }
示例#11
0
 public function onPlace(BlockPlaceEvent $event)
 {
     if (!$event->getPlayer()->hasPermission("customareas.bypass")) {
         foreach ($this->plugin->areas as $area) {
             if ($area->isInside($event->getBlock()) and !$area->canBuild($event->getPlayer())) {
                 $event->setCancelled();
                 $event->getPlayer()->sendMessage("This is " . $area->owner . "'s private area");
             }
         }
     }
 }
示例#12
0
 public function onBanblock(BlockPlaceEvent $event)
 {
     $blocklist = array("46", "327", "10", "11");
     foreach ($blocklist as $Bancode) {
         if ($event->getBlock()->getId() == $Bancode) {
             $event->setCancelled(true);
             $player = $event->getPlayer();
             $player->sendMessage(TextFormat::RED . $player->getName() . "님이 금지된 아이템을 사용하였습니다");
         }
     }
 }
示例#13
0
文件: Tnt.php 项目: NawafCraft/TNT1B
 public function place(BlockPlaceEvent $place)
 {
     $block = $place->getBlock();
     $player = $place->getPlayer();
     if ($block->getId() === 46) {
         $place->setCancelled();
         $mot = (new Random())->nextSignedFloat() * M_PI * 2;
         $tnt = Entity::createEntity("PrimedTNT", $block->getLevel()->getChunk($block->x >> 4, $block->z >> 4), new Compound("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->x + 0.5), new DoubleTag("", $block->y), new DoubleTag("", $block->z + 0.5)]), "Motion" => new EnumTag("Motion", [new DoubleTag("", -sin($mot) * 0.02), new DoubleTag("", 0.2), new DoubleTag("", -cos($mot) * 0.02)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Fuse" => new ByteTag("Fuse", 100)]));
         $tnt->spawnToAll();
         $player->getLevel()->addSound(new AnviluseSound($player), array($player));
         return true;
     }
 }
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if ($this->plugin->cfg->get("debugmode") == "true") {
         $this->plugin->getServer()->getLogger()->info(MT::GREEN . "CommandTest BPosition Place");
     }
     $id = $event->getPlayer()->getID();
     if (in_array($id, $this->schalter)) {
         $bl = $event->getBlock();
         $n = strtolower($event->getPlayer()->getName());
         $this->pos[$n] = new Vector3($bl->getX(), $bl->getY(), $bl->getZ());
         $event->getPlayer()->sendMessage(MT::GOLD . "Position(" . $this->pos[$n]->getX() . "," . $this->pos[$n]->getY() . "," . $this->pos[$n]->getZ() . ")");
         $event->setCancelled(true);
     }
 }
示例#15
0
 /**
  * @param BlockPlaceEvent $event
  *
  * @priority        HIGH
  * @ignoreCancelled true
  */
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->isOp()) {
         return;
     }
     foreach ($this->plugin->getAllZones() as $zone) {
         if ($zone->isIn($event->getBlock())) {
             if ($player->hasPermission($zone->getName() . MEMBER)) {
                 break;
             }
             $event->setCancelled(true);
             $player->sendMessage("[iZone] This is a private area.");
             break;
         }
     }
 }
示例#16
0
 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return boolean
  */
 public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player !== null) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if (!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if (!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         } else {
             return false;
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->canBePlaced()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } elseif ($block->getId() === Item::FIRE) {
         $this->setBlock($block, new Air(), true);
         return false;
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($player !== null) {
             if ($diff = $player->getNextPosition()->subtract($player->getPosition()) and $diff->lengthSquared() > 1.0E-5) {
                 $bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
                 if ($hand->getBoundingBox()->intersectsWith($bb)) {
                     ++$realCount;
                 }
             }
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     $tag = $item->getNamedTagEntry("CanPlaceOn");
     if ($tag instanceof Enum) {
         $canPlace = false;
         foreach ($tag as $v) {
             if ($v instanceof String) {
                 $entry = Item::fromString($v->getValue());
                 if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
                     $canPlace = true;
                     break;
                 }
             }
         }
         if (!$canPlace) {
             return false;
         }
     }
     if ($player !== null) {
         $ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
     }
     if ($hand->place($item, $block, $target, $face, $fx, $fy, $fz, $player) === false) {
         return false;
     }
     if ($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN) {
         $nbt = new Compound("", ["id" => new String("id", Tile::SIGN), "x" => new Int("x", $block->x), "y" => new Int("y", $block->y), "z" => new Int("z", $block->z), "Text1" => new String("Text1", ""), "Text2" => new String("Text2", ""), "Text3" => new String("Text3", ""), "Text4" => new String("Text4", "")]);
         if ($player !== null) {
             $nbt->Creator = new String("Creator", $player->getRawUniqueId());
         }
         if ($item->hasCustomBlockData()) {
             foreach ($item->getCustomBlockData() as $key => $v) {
                 $nbt->{$key} = $v;
             }
         }
         Tile::createTile("Sign", $this->getChunk($block->x >> 4, $block->z >> 4), $nbt);
     }
     $item->setCount($item->getCount() - 1);
     if ($item->getCount() <= 0) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     return true;
 }
 public function onBlockPlace(BlockPlaceEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if ($this->checkBlockPlaceBreak($pl)) {
         return;
     }
     $this->owner->msg($pl, mc::_("You are not allowed to do that here"));
     $ev->setCancelled();
 }
示例#18
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $player = $event->getPlayer();
     if (!$this->isLogin($player)) {
         $event->setCancelled();
         return true;
     }
 }
示例#19
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if ($event->getPlayer()->getLevel()->getName() == $this->getConfig()->get('lobby') and !$event->getPlayer()->hasPermission("skywars.editlobby") || !$event->getPlayer()->hasPermission("skywars")) {
         $event->setCancelled();
         $event->getPlayer()->sendMessage("You don't have permission to edit the lobby.");
     }
     if ($event->getPlayer()->getLevel()->getName() == $this->getConfig()->get('aworld') and $event->getPlayer()->getGameMode() == 3) {
         $event->setCancelled();
     }
 }
示例#20
0
 public function onPlace(BlockPlaceEvent $event)
 {
     if (!$this->isLoggedIn($event->getPlayer())) {
         $event->setCancelled();
     }
     return;
 }
示例#21
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if (isset($this->needAuth[$event->getPlayer()->getName()])) {
         $event->setCancelled();
         $this->deauthenticatePlayer($event->getPlayer());
     }
 }
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $iusername = strtolower($event->getPlayer()->getName());
     if (isset($this->placeQueue[$iusername])) {
         $event->setCancelled();
         unset($this->placeQueue[$iusername]);
     }
 }
示例#23
0
 /**
  * onBlockPlace
  *
  * @param BlockPlaceEvent $event        	
  *
  */
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $allow = $this->checkBlockBreakAndPlacementPermission($event->getPlayer(), $event->getBlock());
         $this->plugin->log("PlayerLobbyListener->onBlockPlace allow: " . $allow);
         if (!$allow) {
             $event->setCancelled(true);
             $this->plugin->log("[HG] PlayerLobbyListener: onBlockPlace cancelled for player " . $event->getPlayer()->getName());
         }
         if ($allow) {
             $event->setCancelled(false);
             $b = $event->getBlock();
             if (!empty($event->getPlayer()->getInventory())) {
                 $event->getPlayer()->getLevel()->setBlock(new Position($b->x, $b->y, $b->z, $b->getLevel()), $b);
                 $this->plugin->log("[HG] PlayerLobbyListener: onBlockPlace ALLOW " . $event->getPlayer()->isOp() . " | " . $event->getPlayer()->getGamemode() . "|" . $event->getPlayer()->getName() . "|" . $event->getPlayer()->getLevel()->getName());
                 $items[] = $event->getPlayer()->getInventory()->getContents();
                 $i = 0;
                 foreach ($items as $index) {
                     foreach ($index as $m) {
                         if ($m->getId() === $b->getId()) {
                             $i = $m->getCount();
                         }
                     }
                 }
                 if ($i > 0) {
                     $i--;
                     $event->getPlayer()->getInventory()->setItemInHand(new Item(Item::AIR));
                     $event->getPlayer()->getInventory()->addItem(new Item($b->getId(), 0, $i));
                 }
             }
         }
     }
 }
示例#24
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $event->setCancelled();
     }
 }
示例#25
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     if (!ServerAuth::getAPI()->isPlayerRegistered($event->getPlayer()->getName()) || !ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
         $event->setCancelled(true);
     }
 }
示例#26
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $username = $event->getPlayer()->getName();
     if (isset($this->placeQueue[$username])) {
         $event->setCancelled(true);
         // No message to send cuz it is already sent by InteractEvent
         unset($this->placeQueue[$username]);
     }
 }
示例#27
0
 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return boolean
  */
 public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player instanceof Player) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face);
         if (!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if ($t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if ($item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->isPlaceable()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } elseif ($block->getId() === Item::FIRE) {
         $this->setBlock($block, new Air(), true);
         return false;
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     if ($player instanceof Player) {
         $ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);
         if (!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if ($t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
     }
     if ($hand->place($item, $block, $target, $face, $fx, $fy, $fz, $player) === false) {
         return false;
     }
     if ($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN) {
         $tile = Tile::createTile("Sign", $this->getChunk($block->x >> 4, $block->z >> 4), new Compound(false, ["id" => new String("id", Tile::SIGN), "x" => new Int("x", $block->x), "y" => new Int("y", $block->y), "z" => new Int("z", $block->z), "Text1" => new String("Text1", ""), "Text2" => new String("Text2", ""), "Text3" => new String("Text3", ""), "Text4" => new String("Text4", "")]));
         if ($player instanceof Player) {
             $tile->namedtag->Creator = new String("Creator", $player->getName());
         }
     }
     $item->setCount($item->getCount() - 1);
     if ($item->getCount() <= 0) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     return true;
 }
示例#28
0
 public function onBlockPlace(BlockPlaceEvent $event)
 {
     $b = $event->getBlock();
     $p = $event->getPlayer();
     $n = strtolower($p->getName());
     if (isset($this->sel1[$n])) {
         unset($this->sel1[$n]);
         $this->pos1[$n] = new Vector3($b->getX(), $b->getY(), $b->getZ());
         $p->sendMessage("Position 1 set to: (" . $this->pos1[$n]->getX() . ", " . $this->pos1[$n]->getY() . ", " . $this->pos1[$n]->getZ() . ")");
         $event->setCancelled();
     } else {
         if (isset($this->sel2[$n])) {
             unset($this->sel2[$n]);
             $this->pos2[$n] = new Vector3($b->getX(), $b->getY(), $b->getZ());
             $p->sendMessage("Position 2 set to: (" . $this->pos2[$n]->getX() . ", " . $this->pos2[$n]->getY() . ", " . $this->pos2[$n]->getZ() . ")");
             $event->setCancelled();
         } else {
             if (!$this->canEdit($p, $b)) {
                 $event->setCancelled();
             }
         }
     }
 }
示例#29
0
文件: placebo.php 项目: EmreTr1/rtr
 public function onPlace(BlockPlaceEvent $event)
 {
     if ($event->getBlock()->distance($event->getPlayer()) > 7) {
         $event->setCancelled();
     }
 }
 public function onPlayerPlaceBlock(BlockPlaceEvent $event)
 {
     $blockID = $event->getBlock()->getID();
     $bl = $event->getBlock();
     $pos = $event->getBlock(new Vector3($bl->x, $bl->y, $bl->z));
     if ($blockID == 54) {
         $block1 = $event->getBlock()->getLevel()->getBlock(new Vector3($bl->x + 1, $bl->y, $bl->z));
         $block2 = $event->getBlock()->getLevel()->getBlock(new Vector3($bl->x - 1, $bl->y, $bl->z));
         $block3 = $event->getBlock()->getLevel()->getBlock(new Vector3($bl->x, $bl->y, $bl->z + 1));
         $block4 = $event->getBlock()->getLevel()->getBlock(new Vector3($bl->x, $bl->y, $bl->z - 1));
         if ($block1->getID() == 54 || $block2->getID() == 54 || $block3->getID() == 54 || $block4->getID() == 54) {
             $event->getPlayer()->sendPopup(MT::RED . "Keine Doppelkisten! - no double chests!");
             $this->debug->onDebug('Doublechest placement');
             $event->setCancelled(true);
         }
     }
 }