1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Chunk::getTile()

Discussion in 'Facepalm' started by Driesboy, Jun 27, 2017.

Thread Status:
Not open for further replies.
  1. Driesboy

    Driesboy Spider Jockey

    Messages:
    34
    GitHub:
    driesboy
    Hello since this commit https://github.com/pmmp/PocketMine-MP/commit/0f79b19fdcc8934756b4cbc6994896c918b58788

    my plugin gives these errors
    Code:
    Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'SW_svile v0.6dev': Argument 2 passed to pocketmine\level\format\Chunk::getTile() must be of the type integer, string given, called in C:\Users\PC\Desktop\GameCraftPE\Skywars\src\pocketmine\level\Level.php on line 1971 on svile\sw\SWlistener
    2017-06-27 [18:18:30] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\level\format\Chunk::getTile() must be of the type integer, string given, called in C:\Users\PC\Desktop\GameCraftPE\Skywars\src\pocketmine\level\Level.php on line 1971" (EXCEPTION) in "src/pocketmine/level/format/Chunk" at line 655

    PHP:
    public function refreshSigns($all true$SWname ''$players 0$slot 0$state '§fTap to join')
        {
            if (!
    $all) {
                
    $ex explode(':'array_search($SWname$this->signs));
                if (
    count($ex) == 0b100) {
                    
    $this->getServer()->loadLevel($ex[0b11]);
                    if (
    $this->getServer()->getLevelByName($ex[0b11]) != null) {
                        
    $tile $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[2], $ex[0b10]));
                        if (
    $tile != null && $tile instanceof Sign) {
                            
    $text $tile->getText();
                            
    $tile->setText($text[0], $text[1], TextFormat::GREEN $players TextFormat::BOLD TextFormat::DARK_GRAY '/' TextFormat::RESET TextFormat::GREEN $slot$state);
                        } else {
                            
    $this->getLogger()->critical('Can\'t get ' $SWname ' sign.Error finding sign on level: ' $ex[0b11] . ' x:' $ex[0] . ' y:' $ex[1] . ' z:' $ex[2]);
                        }
                    }
                }
            } else {
                foreach (
    $this->signs as $key => $val) {
                    
    $ex explode(':'$key);
                    
    $this->getServer()->loadLevel($ex[0b11]);
                    if (
    $this->getServer()->getLevelByName($ex[0b11]) instanceof \pocketmine\level\Level) {
                        
    $tile $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[2]));
                        if (
    $tile instanceof Sign) {
                            
    $text $tile->getText();
                            
    $tile->setText($text[0], $text[1], TextFormat::GREEN $this->arenas[$val]->getSlot(true) . TextFormat::BOLD TextFormat::DARK_GRAY '/' TextFormat::RESET TextFormat::GREEN $this->arenas[$val]->getSlot(), $text[3]);
                        } else {
                            
    $this->getLogger()->critical('Can\'t get ' $val ' sign.Error finding sign on level: ' $ex[0b11] . ' x:' $ex[0] . ' y:' $ex[1] . ' z:' $ex[2]);
                        }
                    }
                }
            }
        }
    this is the code of that function

    full plugin: https://github.com/GameCraftPE/Skywars-Core

    how to fix that?
     
    Last edited: Jun 27, 2017
  2. Driesboy

    Driesboy Spider Jockey

    Messages:
    34
    GitHub:
    driesboy
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    $ex is a string array. You are passing strings to the constructors of Vector3.
     
  4. Driesboy

    Driesboy Spider Jockey

    Messages:
    34
    GitHub:
    driesboy
    PHP:
    public function onInteract(PlayerInteractEvent $ev)
        {
            if (
    $ev->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK)
                return;
            
    //In-arena Tap
            
    foreach ($this->pg->arenas as $a) {
                if (
    $t $a->inArena($ev->getPlayer()->getName())) {
                    if (
    $t == 2)
                        
    $ev->setCancelled();
                    if (
    $a->GAME_STATE == 0)
                        
    $ev->setCancelled();
                    return;
                }
            }
            
    //Join sign Tap check
            
    $key $ev->getBlock()->':' $ev->getBlock()->':' $ev->getBlock()->':' $ev->getBlock()->getLevel()->getName();
            if (
    array_key_exists($key$this->pg->signs))
                
    $this->pg->arenas[$this->pg->signs[$key]]->join($ev->getPlayer());
            unset(
    $key);
        }
    PHP:
    $key $ev->getBlock()->':' $ev->getBlock()->':' $ev->getBlock()->':' $ev->getBlock()->getLevel()->getName();
     
  5. Driesboy

    Driesboy Spider Jockey

    Messages:
    34
    GitHub:
    driesboy
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    I already answered you.
     
Thread Status:
Not open for further replies.
  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.