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

Need a chest filler plugin

Comments in 'Plugin Development' started by Hittmana, Jan 19, 2016.

  1. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    all this simple plugin needs to do is fill all the chests in the current world you are in with random items set in the config file. I would also like there to be a number associated with each item, which you can set, in the config which tells it with what frequency to add those items to the chests. I feel dumb for asking and would appreciate any help! Thanks in advance!
  2. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    All chests? Or specified chests. All might be hard.
  3. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    All chests. But just one time, not refill them.
  4. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Huh... Not sure if its possible to get all chests in an infinite world at the same time.. :/
  5. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    Its not infinite. Its an HG map so it has borders, also i don't necessarily need them filled at the same time instantly, it can be within like 30 seconds- 1 minute in which they are filled.
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    How is that hard? Just foreach them 0.o
    XFuryMCPE and Vaivez66 like this.
  7. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    ? what ? This is an HG map i didn't build so i don't know where all the chests are and there are a lot of them so it would take days to find and fill them all and i would miss some.
  8. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    Has anyone come up with something?
  9. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Are you asking for code or a plugin?
    If you are asking for a plugin you should post in Plugin Request
  10. Hittmana
    Offline

    Hittmana Active Member

    Joined:
    Jul 26, 2015
    Posts:
    224
    Minecraft User:
    move_it
    I am asking for a plugin and will move it there momentarily
  11. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    if you want to reset the chest at a certain Level , try this:

    PHP:
    public function refill(Level $level){// function that refill all chests in the world level , must be an instanceof Level

    $tiles $level->getTiles();   //to get all tiles

    foreach ($tiles as $tile){  //foreach tile in the world
    if($tile instanceof Chest){  // if the tile is a chest
    for($i 0;$i 5;$i++){
    $inv $tile->getInventory();    //the chest inventory

    $items = array(   //The array that you can edit for the Items
    Item::get(27601),
    Item::get(26701),
    Item::get(36404)
    );
    $rnd mt_rand(0count($items) - 1);   // the random index
    $item $items[$rnd];   //the item that is random , i know that i can use array_rand() but it is my idea xD
    $inv->setItem($i$item);   // to add the random item

    }
           
    }
    }

    }
    if you have a worldname and want to refill that try this ->

    PHP:

    $level 
    $this->getServer()->getLevelByName("WorldNameHere");// to get the instanceof Level by a worldname
    $this->refill($level);// to called the refill function that we have defined xD

    tigerza118 and Skullex like this.
  12. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    Thx It Workkkkk !!!!!!!!!!!!!!

Share This Page

Advertisement