API Documentation
Currently in the API there are two events ChestRegenEvent, which is called when a chest regenerates, and RegenChestOpenEvent, which is called when a RegenChest is opened.
- These are just a few of the things you can do with these events
ChestRegenEvent
@EventHandler public void onGenerate(ChestRegenEvent event){ //This will get the chest from the event Chest chest = event.getChest(); //Making a new ItemStack array ItemStack[] items = {new ItemStack(Material.BEDROCK), new ItemStack(Material.ANVIL)}; //You can set the regenerated items event.setRegeneratedItems(items); //You can get the Regenerated items event.getRegeneratedItems(); //You can get the regenReason if(event.getRegenCause().equals(RegenCause.CUSTOM)){ //You can cancel the event event.setCancelled(true); } //You can get the stored items for the specific chest ItemStack[] defaultItems = event.getDefaultItems(); }
RegenChestOpenEvent
@EventHandler public void onOpen(RegenChestOpenEvent event){ //This event is called when you Right Click a regenchest //If it is a perplayerchest, it will be called regardless if it has regenerated Player player = event.getPlayer(); if(!player.hasPermission("TestPermission.Test")){ event.setCancelled(true); }else{ player.sendMessage("Test :D "); ItemStack[] items = {new ItemStack(Material.BEDROCK), new ItemStack(Material.ANVIL)}; //Set the items in the chest event.getChest().setTempInv(items); } }
Comments