Could not pass event 'pocketmine\event\player\PlayerDropItemEvent'

Discussion in 'Development' started by HoRoot, May 17, 2022.

  1. HoRoot

    HoRoot Creeper

    Messages:
    1
    upload_2022-5-17_5-10-26.png
    help me please



    89
    PHP:
        public function onBlockBreak(BlockBreakEvent $event){
            
    $player $event->getPlayer();
            
    $block $event->getBlock();
            
    $x round($block->getX());
            
    $y round($block->getY());
            
    $z round($block->getZ());
            
    $level $block->getLevel()->getName();
            
    $username strtolower($player->getName());
            
    $item $event->getItem()->getID();
            
    $result $this->db->query("SELECT * FROM AREAS WHERE (Pos1X <= $x AND $x <= Pos2X) AND (Pos1Y <= $y AND $y <= Pos2Y) AND (Pos1Z <= $z AND $z <= Pos2Z) AND Level = '" $level "';")->fetchArray(SQLITE3_ASSOC);
            
    $count  $this->db->query("SELECT COUNT(*) as count FROM AREAS WHERE (Pos1X <= $x AND $x <= Pos2X) AND (Pos1Y <= $y AND $y <= Pos2Y) AND (Pos1Z <= $z AND $z <= Pos2Z) AND Level = '" $level "';")->fetchArray(SQLITE3_ASSOC);

            
    $find $x.":".$y.":".$z.":".$level;
            if(isset(
    $this->sells[$find])) {
                
    $region $this->sells[$find]["region"];
                    if(
    $result !== false && $username != $result['Owner'] && !$player->isOp()) {
                        
    $player->sendMessage("§8§l§Aprivate§r§8§r §f➝ §f You are not the owner of this region");
                        
    $event->setCancelled(true);
                        return;
                    }

                
    $this->db->query("UPDATE AREAS SET Sell = '0' WHERE Region = '$region'");
                
    $this->sells[$find] = null;
                unset(
    $this->sells[$find]);
                
    $player->sendMessage("§8§l§Aprivate§r§8§r §f➝ §F Region: §c§l {$region} §r§successfully withdrawn from sale");
            }


            if(
    $item == 288){
                
    $this->pos1[$username] = array($x$y$z$level);
                
    $player->sendMessage("§8§l§Aprivate§r§8§r §f➝ §the first point is set to §c§l({$x}{$y}{$z}).");

                if(isset(
    $this->pos1[$username]) && isset($this->pos2[$username]) && $this->pos1[$username][3] == $this->pos2[$username][3]){
                    
    $pos1 $this->pos1[$username];
                    
    $pos2 $this->pos2[$username];
                    
    $min[0] = min($pos1[0], $pos2[0]);
                    
    $max[0] = max($pos1[0], $pos2[0]);
                    
    $min[1] = min($pos1[1], $pos2[1]);
                    
    $max[1] = max($pos1[1], $pos2[1]);
                    
    $min[2] = min($pos1[2], $pos2[2]);
                    
    $max[2] = max($pos1[2], $pos2[2]);
                    
    $count  $this->countBlocks($min[0], $min[1], $min[2], $max[0], $max[1], $max[2]);
                    
    $player->sendMessage("§8§l§Aprivate§r§8§r §f➝ §f Selected §c§l {$count} §r§fblocks");
                }
                
    $event->setCancelled(true);
            } else {
                
    $member $this->db->query("SELECT COUNT(*) as count FROM MEMBERS WHERE Region = '" $result['Region'] . "' AND Name = '$username'")->fetchArray(SQLITE3_ASSOC);
                
    $flag $this->db->query("SELECT COUNT(*) as count FROM FLAGS WHERE Region = '" $result['Region'] . "' AND Flag = 'build' AND Value = 'allow'")->fetchArray(SQLITE3_ASSOC);
                
    $chest_access_flag $this->db->query("SELECT COUNT(*) as count FROM FLAGS WHERE Region = '" $result['Region'] . "' AND Flag = 'chest-access' AND Value = 'allow'")->fetchArray(SQLITE3_ASSOC);

                
    //if ($result !== false && $username != $result['Owner'] && !$player->isOp() && !$member['count'] && !$flag['count']) {
                     
    if ($result !== false && $username != $result['Owner'] &&  !$member['count'] && !$flag['count']) {
                    if (
    $player->hasPermission('wg.all') && $result['Region'] != 'spawn' && $result['Region'] != 'pvp' && $result['Region'] != 'pvp1' && $result['Region'] != 'pvp2' && $result['Region'] != 'spawn1') return;
                    else {
                        
    $player->addTitle("§8⌊§l§cPrivate§r§8⌉","§fHere region");
                        
    $player->getLevel()->addSound(new ClickSound($player));
                        
    $player->sendMessage("§8§l§aPrivate§r§8§r §f➝ §fYou cannot break blocks in this territory");
                        
    $event->setCancelled(true);
                    }
                }
            }
        }


    160
    PHP:
        public function onEntityDamage(EntityDamageEvent $event){
            
    $entity $event->getEntity();
            if (
    $event instanceof EntityDamageEvent) {
                if (
    $entity instanceof Player) {

                    
    $x round($entity->getX()); $y round($entity->getY()); $z round($entity->getZ());

                    
    $level  $entity->getLevel()->getName();
                    
    $result $this->db->query("SELECT * FROM AREAS WHERE (Pos1X <= $x AND $x <= Pos2X) AND (Pos1Y <= $y AND $y <= Pos2Y) AND (Pos1Z <= $z AND $z <= Pos2Z) AND Level = '" $level "';")->fetchArray(SQLITE3_ASSOC);
                    
    $count $this->db->query("SELECT COUNT(*) as count FROM AREAS WHERE (Pos1X <= $x AND $x <= Pos2X) AND (Pos1Y <= $y AND $y <= Pos2Y) AND (Pos1Z <= $z AND $z <= Pos2Z) AND Level = '" $level "';")->fetchArray(SQLITE3_ASSOC);
                    
    $flag $this->db->query("SELECT COUNT(*) as count FROM FLAGS WHERE Region = '" $result['Region'] . "' AND Flag = 'invincible' AND Value = 'allow'")->fetchArray(SQLITE3_ASSOC);

                    if (
    $count['count'] && $flag['count'])
                        
    $event->setCancelled(true);
                }
            }
        }


    209
    PHP:
        public function onBlockPlace(BlockPlaceEvent $event)
        {
            
    $player $event->getPlayer(); $username strtolower($player->getName());

            
    $block $event->getBlock();

            
    $x round($block->getX()); $y round($block->getY()); $z round($block->getZ()); $level $block->getLevel()->getName();

            
    $result $this->db->query("SELECT * FROM AREAS WHERE (Pos1X <= $x AND $x <= Pos2X) AND (Pos1Y <= $y AND $y <= Pos2Y) AND (Pos1Z <= $z AND $z <= Pos2Z) AND Level = '" $level "';")->fetchArray(SQLITE3_ASSOC);
            
    $member $this->db->query("SELECT COUNT(*) as count FROM MEMBERS WHERE Region = '" $result['Region'] . "' AND Name = '$username'")->fetchArray(SQLITE3_ASSOC);
            
    $flag $this->db->query("SELECT COUNT(*) as count FROM FLAGS WHERE Region = '" $result['Region'] . "' AND Flag = 'build' AND Value = 'allow'")->fetchArray(SQLITE3_ASSOC);
            
    //if ($result !== false and $username != $result['Owner'] and !$player->isOp() and !$member['count'] and !$flag['count']) {
                  
    if ($result !== false and $username != $result['Owner'] and !$member['count'] and !$flag['count']) {
                    if (
    $player->hasPermission('wg.all') && $result['Region'] != 'spawn' && $result['Region'] != 'pvp' && $result['Region'] != 'pvp1' && $result['Region'] != 'pvp2' && $result['Region'] != 'spawn1') return;
                    else {
                        
    $player->sendMessage("§8§l§aPrivate§r§8§r §f➝ §fYou cannot place blocks in this territory");
                        
    $player->addTitle("\n§8⌊§l§cPrivate§r§8⌉","§fHere is a region");
                        
    $player->getLevel()->addSound(new ClickSound($player));
                        
    $event->setCancelled(true);
                    }
            }
        }
    [​IMG][​IMG]
     
    Last edited: May 17, 2022

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.