Code: @EventHandler public void spawnerblock(BlockPlaceEvent event){ Material block = event.getBlock().getType(); Player player = event.getPlayer(); World world = player.getWorld(); Location location = event.getBlock().getLocation(); for (Material spawnzombie : spawner) { if(spawnzombie == block) { do { world.spawnEntity(location, EntityType.ZOMBIE); //need delay here } while(true); } Tried Thread.sleep(), etc but it doesn't seem to work! How can I add delay?
Use runnables: Code: new BukkitRunnable() { int count = 10; public void run() { // Spawn zombie count--; if (count == 0) cancel(); } }.runTaskTimer(plugin, delay, interval-between-spawnings); Using do/while loops for delays don't work, and Thread.sleep() will sleep the main thread, causing the whole server to freeze up and players to be disconnected
Ok, I think I understand how to use it. I'll give it a try. Thanks Ah, may sounds nooby but I have no idea where I'd but this. Do I have to chance the event or what? EDIT by Moderator: merged posts, please use the edit button instead of double posting.