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

Error on addWindow

Comments in 'Plugin Development' started by JackboyPlay, May 11, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    if($player->getInventory()->getItemInHand()->getId() == 146){
    $chest $this->getServer()->getLevelByName("world")->getTile(new Vector3(3061672));
    $player->addWindow($chest->getInventory());
    $player->sendMessage("§c[§aLobby§c] §eDu befindest dich nun im Kleiderschrank!");
    }
    The chest will be opened but only for 0.5 Seconds
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Create new delayed task and give the task $player and $inventory object
    PHP:
    $player->closeWindow($chest->getInventory());
    As far as I remember this should work
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    No you dont understand me the chest closes automaticly after 0.5 Seconds but I dont want it!
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Sorry but be more descriptive next time.

    Few tips:
    • Make sure there is no plugin conflict (Remove all plugins except this and see if the problem still occure)
    • add 'if' statement to check if correct objects are parsed to Player::addWindow(Inventory $inventory)
    • Remove code where you use any function which causes window to close
    • Is the chest too far?
    • Don't teleport player when adding window
    Last edited: May 11, 2016
    JackboyPlay and HotFireyDeath like this.
  5. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Thanks the error was that the chest was too far away
    Primus likes this.
  6. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    How can I check if the player close the chest on the addWIndow function?
  7. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I use it like this:

    1) Give player invisible effect with setVisible(false) and duration 9999 to prevent other players teleporting the player.
    2) Teleport player within 4-5 blocks from the chest
    3) Use addWindow

    On window close (InventoryCloseEvent) schedule task with delay 1tick, and on task run teleport player back to his last position and remove invisible effect
    JackboyPlay likes this.
  8. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Hmm thanks but I have an another idea...
  9. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @Primus
    How did I use the scheduletask?
    Last edited: May 12, 2016
  10. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    And which idea? :D
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Mybe
    scheduled teleport

Share This Page

Advertisement