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

How to capture players hotbar and store it in a chest and save chest in a config

Comments in 'Plugin Development' started by Wantedkillerss, Sep 24, 2014.

  1. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    title says most
    I wanna do like
    $player = $event->getPlayer();
    $ID = $event->getBlock()->getID();
    if($ID == 5){
    $tile = $event->getBlock()->getLevel()->getTile(new Vector3($event->getBlock()->getX(),$event->getBlock()->getY(),$event->getBlock()->getZ(),$event->getPlayer()->getLevel()))
    if($tile instanceof chest){
    $chest->setItem($slot, new Air());
    // and here I put the capture hot bar and then store it in a chest and saving the chest in a config the config withholding the information of what's inside the chest and where is the chest thx :) hope u understood what I said
    $this->config->save();
    LDX likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why save in a config while the chest itself is saved by the server?
  3. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    I think this is just a snippet of the code, so maybe the chest contents need to be different for each player.
    LDX likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then don't use the config. Config files are never good places to store data. Store them in another file (instead of the default config) or use a database instead.
  5. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    I know. We don't know what he wants to do with this yet though, so I could've guessed completely wrong.
  6. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    its a tiny little piece in a huge plugin its just so that every time the thing the plugin does finishes it reloads them with what u did /test capture I thought it'd be cool if it could just capture your hot bar
    Dutok likes this.
  7. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Use
    PHP:
    $player->getInventory() 
    to access player's inventory, for hotbar, use
    PHP:
     $inventory->getHotbarSlotIndex($index)
    To get the inventory slot of that index (the Item itself)
    Dutok likes this.

Share This Page

Advertisement