So I keep on crashing every time I place down stone after the repeating task has been activated. I get the message "Stone in area" but crash right after, with no logs or anything. With no stone it works fine. Code: public void generating(int delay, List<Location> l, Player p, List<Material> bl, Location bloc) { task = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() { @Override public void run() { if(ine != 0) { if (!getNBlocks(bloc, 2).contains(Material.STONE)) { Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { if (getNBlocks(bloc, 2).contains(Material.STONE)) { p.sendMessage("Stone in area"); int r = new Random().nextInt(123); if (l.get(r).getBlock().getType() == Material.STONE) { l.get(r).getBlock().setType(Material.EMERALD_ORE); } else { while (l.get(r).getBlock().getType() != Material.STONE) { r = new Random().nextInt(123); if (l.get(r).getBlock().getType() == Material.STONE) { l.get(r).getBlock().setType(Material.EMERALD_ORE); } } } ine--; return; } p.sendMessage("No stone in area!"); } }, 100, 100);
The while loop isnt the problem. When taken out the same thing happens. Something seems to be starting an infinite loop that keeps on crashing. because the server cant be stopped or reloaded, and no commands are usable.
Normally that is the work of a while loop. If you need one for this then you are doing it wrong Post the full class please