How To Make A Crate Key Plugin?

Discussion in 'Plugin Development' started by Azrex, Apr 26, 2015.

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

    Azrex

    Hi,
    I would like to create a crate key with all the fancy stuff.
    So I would get like an enchanted tripwire hook to act as a crate key and then open it on a specific chest.
    When I would open the chest the prizes that are available would be in the middle which would keep randomizing and on the borders, there would be a decoration such as glass panes.
    I am not asking for the complete code although that would be EPIC!
    As I am new to java, I do not know that much. I have learnt to teleport a person to a random place, although I dont think its really relevant as it is used for Teleportation
    Could you just give me a few tips on how to start off and how the items will remain in the chest etc.

    It would be greatly appreciated :D
     
  2. Offline

    Gater12

  3. Offline

    Azrex

    Thank You @Gater12
    Ill give it a try. :D

    Umm I can't understand what I am trying to find.
    There are lots of commands here, which one is correct?
    And if you have created a crate key plugin, could you send me the code or just a piece of it?
     
    Last edited by a moderator: Apr 27, 2015
  4. Offline

    pie_flavor

    @Azrex So what you want to do, is spawn a chest with a custom inventory at a location (which may be random). Then, set the custom inventory to whatever. Put the name to something custom so you can distinguish it. Listen for a PlayerInteractEvent and check whether they are right clicking the chest, and if they don't have the key, cancel the event. Also listen for an InventoryClickEvent. Check whether they are in the crate inventory, and if they are clicking on the correct item, set it to cancelled, give them the items, delete one crate key, and close the inventory.
     
  5. Offline

    Azrex

    Yes Exactly but I want the chest to be placed at spawn at all times. And also want the item to be different for example Enchanted Tripwire Hook :D
     
  6. Why inventory open event ?
    He can fill the chest before open it .
     
  7. Offline

    Gater12

    @MaTaMoR_
    I was assuming it was like another crate plugin where there is one chest where you right click a chest with key, and you get a reward.
     
  8. He shouldn't do that, if somebody else opens the chest at the same time GG.
     
  9. Offline

    Gater12

    @MaTaMoR_
    That's why you cancel the opening of the chest and open another inventory just for them.
     
  10. So you don't have to use open inventory event, just with interact.
     
  11. Offline

    Gater12

    @MaTaMoR_
    PlayerInteractEvent calls more often then InventoryOpenEvent. Better off listening for that event and check the holder and player.
     
  12. Offline

    Azrex

    Ok so basically I have created the InventoryGUI. Now what I want is to put stained glass panes in the corners which would flicker into different glass panes. Would I have to use a loop for this?
     
  13. Offline

    pie_flavor

    @Azrex Do not use a loop in order to perform sequences of events. Your plugin, and all other plugins, must be executed every 1/20 of a second. Instead, use a sync repeating BukkitRunnable in order to set it for all vaild inventories.
     
  14. Offline

    Azrex

    Could u help me with the BukkitRunnable?
    And If I want to add enchantments to blocks such as grass, how would I do that?
    Plz list the code :D
     
  15. to make a repeating BukkitRunnable, use:
    Code:
    new BukkitRunnable() {
    public void run() {
    
    }
    }.runTaskTimer(this, 0, 1);
     
Thread Status:
Not open for further replies.

Share This Page