Random Fill Chests

Discussion in 'Plugin Development' started by BaconStripzMan, Feb 3, 2015.

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

    BaconStripzMan

    Hello! I am creating a Survival Games plugin (private) for my up-coming minigame server.
    I want to make it so:

    When a player opens an ender chest cancel the open, create a new chest and then fill that with random items. How could I do this, all I have so far is this
    Code:java
    1.  
    2. @EventHandler
    3. public void onInventoryOpen(InventoryOpenEvent e){
    4. Player p = (Player) e.getPlayer();
    5. if(e.getInventory().getType() == InventoryType.ENDER_CHEST){
    6. e.setCancelled(true);
    7. }
    8. }
    9.  
     
  2. Offline

    1Rogue

    So proceed to open a new inventory for them now that you've cancelled the event.
     
    BaconStripzMan likes this.
  3. @BaconStripzMan Like @1Rogue said, make a new inventory, and fill that inventory with random items taken from a list/config. Although, if you want to make it easier, get all the chests in a selected area and put random items in it.
     
    BaconStripzMan likes this.
  4. Offline

    BaconStripzMan

    I know :p I tried creating a new inventory and removing it when they close it. but then any items in the chest would get deleted..

    EDIT: And it would be pretty hard to make multiple chests
     
    Last edited: Feb 3, 2015
  5. Offline

    1Rogue

    You don't need to clear or remove the inventory after, you can just store the reference to it and then open it later.
     
Thread Status:
Not open for further replies.

Share This Page