Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Multiple Players opening Fake chests

Comments in 'Plugin Development' started by CraftYourBukkit, Oct 30, 2015.

  1. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I am having a fakechest but it can only be opened by one Player, when it's being opened by another Player while someone has it opened, the Player is getting "kicked out". Do you know how to fix this?
    PHP:
    public function secretChest($entity) {
            
    $block = new \pocketmine\block\Chest();
            
    $entity->getLevel()->setBlock(new Vector3($entity->getX(), $entity->getY() - 4$entity->getZ()), $blocktruetrue);
            
    $nbt = new Compound("", [
                new 
    Enum("Items", []),
                new 
    String("id"Tile::CHEST),
                new 
    Int("x"$entity->getX()),
                new 
    Int("y"$entity->getY() - 4),
                new 
    Int("z"$entity->getZ())
            ]);
            
    $nbt->Items->setTagType(NBT::TAG_Compound);
            
    $tile Tile::createTile("Chest"$entity->getLevel()->getChunk($entity->getX() >> 4$entity->getZ() >> 4), $nbt);
            
    $config = new Config($this->getDataFolder() . "/config.yml"Config::YAML);
            
    $all $config->get("buyable");
            
    $tile->getInventory()->clearAll();
            for (
    $i 0$i count($all); $i $i 2) {
                
    $slot $i 2;
                
    $tile->getInventory()->setItem($slotItem::get($all[$i], 01));
            }
            return 
    $tile->getInventory();
        }
    I am using
    PHP:
    $player->addWindow($this->secretChest($event->getEntity()));
    to open the chest.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  3. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Lol
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What was the solution?
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I was spawning the chest at the same place all the time when opening it
    PocketKiller and Legoboy0215 like this.

Share This Page

Advertisement