Hey there. I have been trying to create a randomly generated event for ages, but can't figure out how it works. That's why I'd like to ask you if you do know how. And if yes, please leave a reply telling me how. Let me explain the problem: I need two randomly generated events. The first one: if you use a magmacream on the ground, you can get several items. Item 1 has for example a chance of 100% on appearing in your inventory. And item 2 has 50%. The second randomly chosen event is when a player places a block. There should be about 5% chance for the player to get a certain amount of items. Thanks for reading, hope I can finish my plugin now
If you mean "interact" instead of "use" then use PlayerInteractEvent. Use BlockPlaceEvent. For getting a percentage of happening, I think it would look something like this: Code:java Random random = new Random();int chance = 5;int percentage = random.nextInt(99) + 1; //From 1 - 100if(chance < percentage){ //Do something}